0

how to retirve user input data from included zuml component

asked 2010-03-15 04:47:49 +0800

dickdastardly gravatar image 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
address etc..

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 flag offensive retag edit

15 Replies

Sort by ยป oldest newest

answered 2010-03-15 21:27:16 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

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>

link publish delete flag offensive edit

answered 2010-03-16 00:18:59 +0800

dickdastardly gravatar image dickdastardly
168 1 5

Jimmy

thankyou very much for spending your time replying...

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

link publish delete flag offensive edit

answered 2010-03-16 19:56:13 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Is this sample you want ?

index.zul

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

page1.zul

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

link publish delete flag offensive edit

answered 2010-03-17 00:03:06 +0800

dickdastardly gravatar image 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?

link publish delete flag offensive edit

answered 2010-03-17 01:17:24 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Could you post your sample code for reproduce exception ?

link publish delete flag offensive edit

answered 2010-03-17 14:51:12 +0800

dickdastardly gravatar image 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?

link publish delete flag offensive edit

answered 2010-03-17 20:19:10 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

updated 2010-03-17 21:47:38 +0800

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="Your name:"/>
	<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>

link publish delete flag offensive edit

answered 2010-03-19 05:31:20 +0800

dickdastardly gravatar image dickdastardly
168 1 5

Dear Potix Jimmy

Sorry to "Bang on" :-) about this

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?

this link http://docs.zkoss.org/wiki/Developer_reference_The_XUL_Components_Components_Include

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}

link publish delete flag offensive edit

answered 2010-03-19 08:39:35 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

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

link publish delete flag offensive edit

answered 2010-03-19 12:07:22 +0800

dickdastardly gravatar image 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

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-03-15 04:47:49 +0800

Seen: 937 times

Last updated: Mar 23 '10

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