1

how can i get data from another page

asked 2014-03-12 18:20:20 +0800

Kammoun gravatar image Kammoun
13 2

updated 2014-03-13 13:23:35 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

I need to communicate objects (data) between two pages .

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2014-03-12 20:27:48 +0800

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

updated 2014-03-13 22:09:01 +0800

Oke, now I get it.

If you are gonna do a sendRedirect to another page, you some options.

Option 1: Do a GET to that zul :

sender :

Executions.sendRedirect("second.zul?username=MyName");

receiver :

String username = Executions.getCurrent().getParameter("username");

Option 2 : Store it in your session scope :

store it :

User currentUser = new User();
Session session = Sessions.getCurrent();
session.setAttribute("user", currentUser);

get it from session :

Session session = Sessions.getCurrent();
User currentUser =(User) session.getAttribute("user");

Option 3 : Do a POST method :

well, search for yourself and you will find it how to do it, lots of examples online and with one of the 2 above it will work also.

Hope this helps you.

Greetz chill.

link publish delete flag offensive edit

Comments

thank you :)

Kammoun ( 2014-03-13 22:18:21 +0800 )edit

your welcome. Sorry for confusing but with zk you can add pages to masterpage and so on what mostly creates headaches to people

chillworld ( 2014-03-13 22:21:51 +0800 )edit
0

answered 2014-03-13 14:27:56 +0800

BenAmarMahdi gravatar image BenAmarMahdi
1

ok, so this a simple exemple i make to test it between 2 pages a.zul et b.zul

a.zul(sender)

<?page title="a" contentType="text/html;charset=UTF-8"?> <zk> <window title="new page title" border="normal" apply="NouvaPoule.Elevage.controller.aC"> <textbox id="t"/> <button id="b" label="go"/> </window> </zk>


a.controller

`public class aC extends SelectorComposer<window> { @Wire Textbox t;

@Listen("onClick=#b")
public void aa() throws IOException {
    Map<String,Object> args = new HashMap<String,Object>();
    args.put("data", t.getValue());
    BindUtils.postGlobalCommand(null, null, "doSomeThing", args);
    Executions.sendRedirect("b.zul");

} }`


b.zul ( receiver)

<?page title="new page title" contentType="text/html;charset=UTF-8"?> <zk> <window title="new page title" border="normal" apply="NouvaPoule.Elevage.controller.bC"> <label id="l"/> </window> </zk>


b.controller

public class bC extends SelectorComposer<window>{

private static final long serialVersionUID = 1L;

@Wire Label l; @Override public void doAfterCompose(Window comp) throws Exception { super.doAfterCompose(comp);

}

@GlobalCommand
public void doSomeThing(@BindingParam("data") String data){
   l.setValue(data);
}

} `

link publish delete flag offensive edit

Comments

ah lols oke, I get it, your 2 pages aren't included in one page? so one pc has screen A and other pc has screen B open?

chillworld ( 2014-03-13 16:13:04 +0800 )edit

no in the same pc ! the click on the button should redirect me to page b and the data show appears in page b.

BenAmarMahdi ( 2014-03-13 17:04:17 +0800 )edit
0

answered 2014-03-13 12:46:05 +0800

BenAmarMahdi gravatar image BenAmarMahdi
1

please , is there anything to add to ZUL pages ?? because i have tried the same solution from the beggining and it didn't work.

link publish delete flag offensive edit

Comments

post your code and we we will show you where it goes wrong (zul and vm/controller the important piece only) and in what scope are your 2 pages?

chillworld ( 2014-03-13 13:43:24 +0800 )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
3 followers

RSS

Stats

Asked: 2014-03-12 18:20:20 +0800

Seen: 45 times

Last updated: Mar 13 '14

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