0

IMPORTANT: Get Value of Component on another ZK Page

asked 2011-01-14 07:16:14 +0800

knex gravatar image knex
84 1

updated 2011-01-14 08:18:40 +0800

?? MAIN QUESTION OF THIS THREAD ???

------------------------------------------------------------------------

How can I get Components or the CodeBehind Class of another ZK Page?
I am on page A (page a is includet in page b) and I want to change a Componentvalue of Page B...
How do I do that?

--------------------------------------------------------------------------

DETAILED PROBLEM


the solutions was to change the src of the include component in the frame page...
but...
this solution is not working too.
I tryed defining the Modal-Window Class as an interface.
It all worked fine, but for one user only, if I open up the project with antother browser it says

Access denied: component, <Toolbarbutton diag>, belongs to another desktop: [Desktop zd_krt1:/gui/patientrecord/main.zul]

Shure, but I have no idea how to Navigate then from Includet Window.
Try to work with getFellow doesnt work ether...
Example:


Zul Page Frame

toolbarbutton...
then..
     </columns>
                </grid>
            </north>

            <center>
                <include id="inc" src="@{winCareFrame.src}"/>

            </center>


Modal Window Frame Page

private Include inc;
    private String src;
    private static Frame instance;
    private boolean open;


   /**
     * @return the instance
     */
    public static Frame getInstance() {
        if (instance == null) {
            instance = new Frame();
        }
        return instance;
    }

    public Frame() {
       
        this.setMaximizable(true);
        if (Executions.getCurrent().getArg().get("src") != null) {
            src = Executions.getCurrent().getArg().get("src").toString();
        } else {
            src = "/gui/patientrecord/modules/care/care_process.zul";
        }
    }

    @Override
    public void onClose() {
        this.detach();
        open = false;
    }

    public void afterCompose() {
       instance = this;
        open = true;
        inc = (Include) getFellow("inc");
       
    }

   /**
     * Ändert den Inhalt der eingebundenen Seite
     * Öffnet wenn nötig das Modale Fenster
     * @param src
     */
    public void setSource(String src) {  <<<< // Changes the Src of the Include 

   
            inc.setSrc(src);
        }

    }

Event Listener in Includet Page to change the content of the Frame

tree_row.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener() {

                        public void onEvent(Event event) throws Exception {
                            Treerow row = (Treerow) event.getTarget();
                            logger.debug("Choose: " + row.getAttribute("goal_id"));
                            Frame.getInstance().setSource("/modul/care_goal.zul?goal_id=" + row.getAttribute("goal_id")); <<<<
                        }
                    });


I hope you have an idea how to set the source of the Frames Include.
Maybe with executions. How can I get the Frame Object an call it´s methods?

Thank you very much for your help.
I prize that very much.

Kind regards

delete flag offensive retag edit

4 Replies

Sort by » oldest newest

answered 2011-01-14 08:47:57 +0800

flyworld gravatar image flyworld
155 3

hi,
after review your code, i found out that you can do better in ZK !
imo, while developing in ZK, i never use "Frame" or "include"

instead of these, i would use pure ZUL to template and allocate the components,

<?page title="ZK Store - Login"?>
<window id="loginWin" border="normal" width="300px"
    title="You are using: ${desktop.webApp.version}"
    apply="demo.web.ui.ctrl.LoginViewCtrl">
     
    <grid>
        <rows>
            <row> Name: <textbox id="nameTxb"/></row>
            <row> Password:<textbox id="passwordTxb"  type="password"/></row>
        </rows>
    </grid>
    <button id="confirmBtn" label="confirm"/>
    <label id="mesgLbl"/>
</window>

then using ZK MVC to separate the UI and controller (it is a ZK composer)

about the problem you met, that's very easy,
i save the composer into ZK session

public class LoginViewCtrl extends GenericForwardComposer {
 
    private Textbox nameTxb;
    private Textbox passwordTxb;
    private Label mesgLbl; 
    public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);
      session.setAttribute("MY_COMPOSER1",this);
   }

}

the i can take this composer by using session.getAttribute("MY_COMPOSER1");

if i want to change anything in that composer, i cat create method to do it !

problem solved =)

link publish delete flag offensive edit

answered 2011-01-14 09:12:58 +0800

knex gravatar image knex
84 1

Yeah,
Thank you so much, You saved my day. And maybe the hole Project.
I´m doin it like you say with ZK and MVC I just named the Class Frame
and Include is a ZK Component.
I had the same Idea putting the Frame into the Session but I addet it inside the Construcor :-D
It is working fine and I am more happy than anyone else can be in this world.
It was very important for me to solf it.
And YOU heped me so much.
Thank you I appriciate this.
God bless you!

SOLVED! :-D yippi ya yeah

link publish delete flag offensive edit

answered 2011-01-14 09:35:26 +0800

flyworld gravatar image flyworld
155 3

great =)

the way you used might be a new way of ZK's pattern i've seen ...:p

but that's why i choose ZK in my projects, it's really powerful and users can finish their job easily :D

link publish delete flag offensive edit

answered 2011-12-13 04:32:10 +0800

Djbhuva gravatar image Djbhuva
27

you both were saved my time too.. thanks a lot..

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: 2011-01-14 07:16:14 +0800

Seen: 1,369 times

Last updated: Dec 13 '11

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