# how to retirve user input data from included zuml component

dickdastardly
168 1 5

Dear ZK Forum (you hav'nt let me down so far :-))

I am attempting to develop a small application for personal details of a family

The parents details are collected and have repeated fields such as Title, first name, middle name, & surname

I thought I could create a "sub" zuml page with these common textbox input fields and so keep my code (zuml) clean
so that i did not repeat myself.

The problem i face is that even though the whole page displays correctly I cannot retieve the entered data of the included zuml
parts!.

I do not want to write any java code to achieve this.

Why do i not have access to the data entered into the textbox of the included page?

am I being very dense?

Cheers

DD

delete retag edit

## 15 Replies

jimmyshiau
4921 5
http://www.zkoss.org/

Hi, dickdastardly
I write a sample

index.zul

<zk>
<label value="outer:"/>
<textbox id="outerbox"/>
<include id="include" src="page1.zul"/>
<button label="save inner" onClick='outerbox.value = ((Textbox)include.getFellow("innerbox")).value'/>
</zk>



page1.zul

<zk>
<label value="inner:"/>
<textbox id="innerbox"/>
</zk>


dickdastardly
168 1 5

Jimmy

The solution i am looking for is to use entirely zuml,

is there a way to use requestScope.myPassedInSessionAttribue as shown here

			<row>
<label value="First Name" width="100px" />
<textbox
value="@<{requestScope.myPassedInSessionAttribue>.middleName, save-when='self.onChange'}"
width="190px" />
</row>
<row>
<label value="Surname" width="100px" />
<textbox
value="@<{requestScope.myPassedInSessionAttribue>.surname, save-when='self.onChange'}"
width="190px" />
</row>



this way i have one .zul file that can be included in any other that needs to collect the first, middle, and surname of customers.
why doesnt this work

jimmyshiau
4921 5
http://www.zkoss.org/

Is this sample you want ?

index.zul

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<zk>
<include id="include" src="page1.zul"/>
<label value="@{requestScope.surname}"/>
</zk>


page1.zul

<zk>
<label value="Surname:"/>
<textbox id="innerbox" value="@{requestScope.surname, save-when='self.onChange'}"/>
</zk>



dickdastardly
168 1 5

Yes

however when i try this I get an exception

did i mention i am using Spring?

Could that be the reason for the failure?

jimmyshiau
4921 5
http://www.zkoss.org/

Could you post your sample code for reproduce exception ?

dickdastardly
168 1 5

Dear Potix Jimmy

first let me say thankyou for bothering with thsi

the included zul file looks like this

<div>
<grid fixedLayout="false">
<columns>
<column label="" width="25%" />
<column label="" width="25%" />
</columns>
<rows>
<row>
<label value="Title" />
<combobox model="@{preSchoolReferenceData.titles}"
selectedItem="@<{requestScope.person>.firstName, save-when='self.onChange'}"
width="190px" />
</row>
<row>
<label value="Middle Name" width="100px" />
<textbox
value="@<{requestScope.person>.surname, save-when='self.onChange'}"
width="190px" />
</row>
</rows>
</grid>
</div>


for some reason the leading "$" and trailing "}" are removed from the code block! The (partial) including zul page looks like this <?xml version="1.0" encoding="UTF-8" ?> <?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?> <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?> <zk> <window title="B U R H A M PreSchool" border="normal" width="100%" height="100%"> <borderlayout height="100%"> <north size="40%" flex="true" maxsize="250" splittable="true" collapsible="true"> </north> <center border="normal"> <borderlayout> <west title="Mum" size="33%" flex="true" maxsize="300" splittable="true" collapsible="true"> <include src="motherName.zul" person="${mother}"/>
</west>
<center title="Child">
<div>
<grid fixedLayout="false">
<columns>
....
....
....


What have i done wrong?

jimmyshiau
4921 5
http://www.zkoss.org/

You cannot combine ''@" and "$" together. modify selectedItem="@{${requestScope.person}.title }" to selectedItem="@{requestScope.person.title}"

but it will not change in outside after you change inside textbox

you have to get the bean and store in a variable

index.zul

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<zk>
<zscript><![CDATA[
import bean.Person;
requestScope.put("person", new Person("Jimmy"));
Person person = (Person)requestScope.get("person");
]]></zscript>
<label value="@{person.name}"/>
<include src="page1.zul"/>
<label value="outer:"/>
<textbox value="@{person.name, save-when='self.onChange'}"/>
</zk>



page1.zul

<zk>
<label value="inner:"/>
<textbox value="@{person.name, save-when='self.onChange'}"/>
</zk>


dickdastardly
168 1 5

Dear Potix Jimmy

I am using spring mvc and have a complete zul page working correctly updating my spring backing beans
using @{} in my complete page.

As I have triplicated the same set of tags for Title, first name, middle name, surname i wanted to place these in a partial zul page
and include it three different times, each time passing a different spring backing bean to be updated.

Doesnt zk support passing in a backing bean to be updated in this way?

whats the point of supplying an

<include />
tag if it cannot affect/update the input argument
with user input data?

I thought coding this in outer.zul would insert a requestScope argument called person?

 <include src="inner.zul" person={mother}/>

why do i have to create zscript to do this explicitly?

gave me the impression

Pass Values to the Included Page

There are two ways to pass values to the included page. First, you can pass them with the query string.

<include src="mypage?some=something"/>

Then, in the included page, you can access them with the getParameter method of the Execution interface or the ServletRequest interface. In EL expressions (of the included page), you can use the param variable to access them. However, you can only pass String-typed values with the query string.

${param.some} Alternatively, we can pass any kind of values with the so-called dynamic properties by use of the setDynamicProperty method or, in ZUL, a dynamic property as follows: <include src="mypage" some="something" another="${expr}"/>

With the dynamic properties, you can pass non-String-typed values. In the included page, you can access them with the getAttribute method of the Execution interface or the ServletRequest interface. In EL expressions (of the included page), you can use the requestScope variable to access them.

\${requestScope.some}

jimmyshiau
4921 5
http://www.zkoss.org/

No problem, dickdastardly
is the wiki solve your problem ?
because I have to survey how to use spring backing beans ^^"

dickdastardly
168 1 5

PJ

I still cant get my included page to work :-(

I think its my lack of ZK knowledge

The spring backing beans work a treat, I could do a lot with spring 3 @controllers just using spring sessionattribues
without using the

<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
!.

it was only when i wanted to use actual spring beans for data access like geting my reference data lists that I needed
the DelegatingVariableResolver.

Can you recommend a good source of ZK documentation that may help me solve my include page problem?

Cheers

DD

[hide preview]