0

reload browser problem v.s. data binding failed

asked 2009-05-05 07:10:52 +0800

hawk gravatar image hawk
3225 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2009-05-05 07:13:15 +0800

I have a problem which is similar with this post:
http://www.zk1.org/forum/index.zul#path%3DlistComment%3BdiscussionId%3D6909%3BcategoryId%3D14%3B

I apply the solution, change my composer from singleton spring bean to "prototype".

but I found my listbox with annotation data binding failed, it always get null.
I initilize all data in composer's doAfterCompose(Component comp).
I have found the listbox might get data from different composer bean by tracing the code.
and after I change back my bean to "singleton", the listbox will get the data successfully.

But this way will suffer "the reload browser problem",
that means if you reload the browser, that page will show the error:
You cannot access components belong to other desktop
org.zkoss.zk.ui.UiException: You cannot access components belong to other desktop
at org.zkoss.zk.ui.AbstractComponent.checkDetach(AbstractComponent.java:508)
...
that page with this exception can not be displayed even you logout and login again.

Do anyone know how to deal with it? thanks.


The following brief describe the related page and code:

rentingListbox is a self-defined class which inherit ZK's Listbox.
.zul page

<?page title="" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<zk>
<window id="win" apply="${rentComposer}">

<listbox id="rentingListbox" use="RentingListbox">
<listhead sizable="true">
<listheader label="a" width="30px" />
<listheader label="b" />
<listheader label="c" width="60px" />
<listheader label="d" width="380px" />
<listheader label="e" width="180px" />
</listhead>
</listbox>
<listbox id="myRentListbox" model="@{rentComposer.myRentRecord}">
<listhead sizable="true">
<listheader label="1" width="30px" visible="false"/>
<listheader label="2" />
<listheader label="3" width="60px" />
<listheader label="4" width="180px" />
<listheader label="5" />
</listhead>
...
</listbox>
</window>
</zk>

public class RentComposer extends GenericAutowireComposer {

public void doAfterCompose(Component comp) throws Exception {
//initialize myRentRecord
}
public List<RentRecord> getMyRentRecord() {
return myRentRecord;
}

public void setMyRentRecord(List<RentRecord> myRentRecord) {
this.myRentRecord = myRentRecord;
}
}

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-10-28 10:55:26 +0800

carpolva gravatar image carpolva
155 4

I have the same problem :(

link publish delete flag offensive edit

answered 2011-10-28 15:00:18 +0800

carpolva gravatar image carpolva
155 4

Hi!!.... I've solved my problem :D

I had my controller definition like the following:

<window id="win" width="1845px" apply="${sessionScope.myBean}">

and I changed it by:

        <zscript>
		<![CDATA[
			import com.domain.bean.MyBean;
			MyBean myBean = new MtBean();
		]]>
	</zscript>

	<window id="win" width="1845px" apply="${myBean}">

Because at session initialization

apply="${sessionScope.myBean}"
only one instance of myBean will be used during all the application lifetime, so when a user refresh the page (F5) a new desktop is created and conflicts with the previous created components (of that controller instance) thinking they belong to the previous desktop. Instead with the second way every time the page is reloaded a new desktop and a new controller are created.

But I see you are using Spring right?:

<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
... so, I suggest you to change your composer from singleton spring bean to "prototype".

Regards.

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: 2009-05-05 07:10:52 +0800

Seen: 636 times

Last updated: Oct 28 '11

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