0

passing values

asked 2010-04-21 22:39:41 +0800

shamna gravatar image shamna
84 1

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

delete flag offensive retag edit

10 Replies

Sort by ยป oldest newest

answered 2010-04-21 23:54:37 +0800

SimonPai gravatar image SimonPai
1696 1

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

link publish delete flag offensive edit

answered 2010-04-22 01:01:25 +0800

shamna gravatar image shamna
84 1

hi simon,

I will have to more values during when this is a little complex right. Is there any other way?

link publish delete flag offensive edit

answered 2010-04-22 01:23:49 +0800

shamna gravatar image shamna
84 1

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");
..

link publish delete flag offensive edit

answered 2010-04-22 02:13:08 +0800

SimonPai gravatar image SimonPai
1696 1

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

link publish delete flag offensive edit

answered 2010-04-22 02:59:26 +0800

shamna gravatar image shamna
84 1

Hi simon
Thank for your response. Its working.

link publish delete flag offensive edit

answered 2010-04-23 02:26:00 +0800

shamna gravatar image shamna
84 1

Simon
I get a null value in my second parameter..
Code is
Executions.sendRedirect("/zuls/linechart.zul?date1="+formatdate +"?mrd="+tbmrd.getValue());

link publish delete flag offensive edit

answered 2010-04-23 02:26:45 +0800

shamna gravatar image shamna
84 1

I get an error while giving as

Executions.sendRedirect("/zuls/linechart.zul?date1="+formatdate +"&mrd="+tbmrd.getValue());

link publish delete flag offensive edit

answered 2010-04-23 04:29:11 +0800

SimonPai gravatar image SimonPai
1696 1

What's the error message? Can you post it?

Simon

link publish delete flag offensive edit

answered 2010-04-23 08:38:59 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

    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>

link publish delete flag offensive edit

answered 2010-04-24 07:43:08 +0800

shamna gravatar image shamna
84 1

i got it. Thanx for ur reply

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-04-21 22:39:41 +0800

Seen: 723 times

Last updated: Apr 24 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More