0

Pass information between zul (include) using Include.setDynamicProperty Problem

asked 2015-01-19 23:16:58 +0800

andres565 gravatar image andres565
1

updated 2015-01-19 23:18:52 +0800

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() {
    }
}
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-01-20 05:33:40 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

updated 2015-01-20 05:43:50 +0800

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.

example:

Session.setAttribute("mineObject",object);

and in the included zul :

 MineObject object = null;
 if (Session.getAttribute("mineObject")!=null) }
   object = (MineObject)Session.removeAttribute("mineObject"); 
 }

Greetz chill.

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2015-01-19 23:16:58 +0800

Seen: 53 times

Last updated: Jan 20 '15

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