-
FEATURED COMPONENTS
First time here? Check out the FAQ!
hi,
I have a zul file from which its redirected to another zul file by a button click. I want to get the textbox value of first zul file in the second zul file. Can anybody plz help me.... It is very urgent
Hi shamna,
You can pass it through GET request parameter.
For example,
in file1.zul
<textbox id="myTextBox" /> <button label="Go"> <attribute name="onClick"><![CDATA[ Executions.sendRedirect("file2.zul?var1=" + myTextBox.getValue()); ]]></attribute> </button>
in file2.zul
<label id="myLabel" /> <zscript><![CDATA[ myLabel.setValue(execution.getParameter("var1")); ]]></zscript>
Regards,
Simon
hi simon,
I want to pass a date got from a datebox to the other zul file. I tried the above said way. I get a null value.
The code is;
file1:
.....
Executions.sendRedirect("/zuls/linechart.zul?date1="+db1.getvalue());
file2:
..
Date datevalue=execution.getParameter("date1");
..
shamna,
GET request parameters are strings. If you want to pass a date and retrieve it, you need to format and parse them using a java DateFormat object.
If the value is null then it means either you get a null value from your datebox/textbox, or you fail to retrieve it from GET request parameters.
When redirected to your file2.zul, check the url to see if you have the value correctly passed.
The examples I post is always tested, so it should work.
file1.zul
<textbox id="myTextBox" /> <datebox id="myDateBox" /> <button label="Go"> <attribute name="onClick"><![CDATA[ java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(); Executions.sendRedirect("file2.zul?var1=" + myTextBox.getValue() + "&var2=" + sdf.format(myDateBox.getValue())); ]]></attribute> </button>
file2.zul
<label id="myLabel" /> <zscript><![CDATA[ myLabel.setValue(execution.getParameter("var1")); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(); Date myDate = sdf.parse(execution.getParameter("var2")); ]]></zscript>
Regards,
Simon
I will have to more values during when this is a little complex right. Is there any other way?
Yes, remember, you're running a web app. Put the domain object that contains all the values into the session before the redirect. After the redirect, in your destination zul or composer, get the domain object from the session and use its properties.
Sessions.getCurrent().setAttribute("myObject", object ) ; Executions.sendRedirect( "/zuls/linechart.zul" ) ;
and in the destination:
<zscript> import MyClass ; MyClass object = (MyClass)Sessions.getCurrent().getAttribute( "myObject" ) ; </zscript>
Asked: 2010-04-21 22:39:41 +0800
Seen: 723 times
Last updated: Apr 24 '10