-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I want to set some values in HttpServletRequest and pass it to another zul page. But it doesn't work. Though it works when i set attribute in session and get the value in zul file. I don't want to pass the value in query string as parameter.
Below are my zul file:
page1.zul
<zk> <window apply="RequestParams"> <textbox id="textBox1"></textbox> <button label="Submit" id="submit1"></button> </window> </zk>
page2.zul
<zk> <zscript><![CDATA[ import javax.servlet.http.HttpServletRequest; HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest(); String testValue = (String) request.getAttribute("test"); ]]></zscript> <window> <label value="${testValue }"></label> </window> </zk>
RequestParams.java
public class RequestParams extends SelectorComposer { @Wire Textbox textBox1; @Listen("onClick = button#submit1") public void submitClick() throws IOException { System.out.println("In Submit " + textBox1.getText()); //Executions.getCurrent().getSession().setAttribute("test", textBox1.getText()); HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest(); request.setAttribute("test", textBox1.getText()); Executions.sendRedirect("page2.zul"); } }
Can any body please suggest what i'm doing wrong here? Or what is the correct approach to set some attributes in HttpServletRequest?
Well, you are using a redirect which will cause the browser to make another request. Since its a different request than the first one, you cannot share any data with request attributes. The only choices are using the URL or the session.
Asked: 2013-01-07 09:37:09 +0800
Seen: 74 times
Last updated: Jan 08 '13