First time here? Check out the FAQ!
Hi guys,
I am trying to pass information from one zul to another using Include.setDynamicProperty and ${requestScope.} but it nos working properly. I have being checking the forum but I did not find an answer.
I tried with Should I add another command or is a problem with my configuration?.
I tried with <include src="myzul.zul?some=something"/> and ${param.some} and is working, but I need to pass objects. My codes are really simple since I am just focusing in this issue right now. Thanks for your help.
index.zul
<window id="winmember" border="normal" width="100%" height="100%" apply="com.test.andres.MyViewModel">
<button id="button" label="click" />
<include id="test1" mode = "defer" src="/erp/first.zul" />
<include id="test2" src="/erp/first.zul?test=test2" />
</window>
first.zul
<window id="winfirst" border="normal" apply="com.test.andres.First">
${requestScope.abc}
${param.test}
</window>
MyViewModel.java
public class MyViewModel extends SelectorComposer<Component>
{
private static final long serialVersionUID = 1L;
@Wire private Include test1;
@Listen ("onClick = #button")
public void testing()
{
test1.setDynamicProperty("abc", new String("test1"));
}
}
First.java
public class First extends SelectorComposer<Component>
{
private static final long serialVersionUID = 1L;
public First() {
}
}
You did saw this document.
You use the setDynamicProperty
but why do you make the assumtion this is not for objects?
Lets see in the Include docs :
setDynamicProperty
public void setDynamicProperty(java.lang.String name, java.lang.Object value)
Adds a dynamic property that will be passed to the included page via the request's attribute.
For example, if setDynamicProperty("abc", new Integer(4)) is called, then the included page can retrieved the abc property by use of ${reqestScope.abc}
Specified by:setDynamicProperty in interface DynamicPropertiedSince:3.0.4
So you can actually give an object in this way.
There is also a second solution : The session.
For some cases, I'll put an object in the session and in the included zul I fetch and remove the object out the session.
Session.setAttribute("mineObject",object);
and in the included zul :
MineObject object = null;
if (Session.getAttribute("mineObject")!=null) }
object = (MineObject)Session.removeAttribute("mineObject");
}
Greetz chill.
Asked: 2015-01-19 23:16:58 +0800
Seen: 53 times
Last updated: Jan 20 '15