0

Select a Tab with fulfilled Tabpanel

asked 2007-08-21 14:05:11 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4476399

By: abhigyan

I have a tab which has a 'fulfill' condition. I would like to select the specific tab programmatically.

Following is the code:

<zk>
<window border="normal" id="wnd" xmlns:h="http://www.w3.org/1999/xhtml">
<label id="lab" />
<tabbox width="100%" id="tab">
<attribute name="onCreate">
Events.postEvent("onSelect",A1,null);
</attribute>
<tabs>
<tab label="Tab 1" id="A1" width="20%" selected="true" /> <tab label="Tab 2" id="A2" width="20%" /> </tabs> <tabpanels> <tabpanel fulfill="A1.onSelect"> <tabbox width="100%" id="tabI"> <attribute name="onCreate"> Events.postEvent("onSelect",A1_1,null);
</attribute>
<tabs>
<tab label="1.1" id="A1_1" selected="true" /> <tab label="1.2" id="A1_2" /> </tabs> <tabpanels> <tabpanel fulfill="A1_1.onSelect">1.1</tabpanel>
<tabpanel fulfill="A1_2.onSelect">1.2</tabpanel>
</tabpanels>
</tabbox>
</tabpanel>
<tabpanel fulfill="A2.onSelect">
<tabbox width="100%" id="tabII">
<attribute name="onCreate">
Events.postEvent("onSelect",A2_1,null);
</attribute>
<tabs>
<tab label="2.1" id="A2_1" />
<tab label="2.2" id="A2_2" />
</tabs>
<tabpanels>
<tabpanel fulfill="A2_1.onSelect">2.1</tabpanel>
<tabpanel fulfill="A2_2.onSelect">2.2</tabpanel>
</tabpanels>
</tabbox>
</tabpanel>
</tabpanels>
</tabbox>
<zscript>
wnd.getFellow("A1_2").setSelected(true);
</zscript>
</window>
</zk>

Currently when I try to set A1_2 as selected (using the zscript at the end), since there is a fulfill condition on the tabpanel it is associated with, it gives an error: 'Fellow component not found: A1_1'.

Is there any way this can be achieved?

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2007-08-21 15:19:41 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4476564

By: abhigyan

Sorry the error message is 'Fellow component not found: A1_2'. It can be reproduced by pasting the above code in the zkoss demo.

/abhigyan

link publish delete flag offensive edit

answered 2007-08-22 00:34:29 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4477563

By: robbiecheng

Please remove the following lines,

<zscript>
wnd.getFellow("A1_2").setSelected(true);
</zscript>

You could not access a component until the condition specified in the fulfill is satisfied.
In other words, the component hasn't been creatd.

robbie

link publish delete flag offensive edit

answered 2007-08-22 10:15:40 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4478097

By: abhigyan

Ok, my requirement is:

1. On demand loading of all the tabs, since the contents on each of those tabs are very huge. So, if I allow all tabs to be loaded at the same time, it will degrade the performance (as it is doing now).
Solution: use the 'fulfill' attribute for the tabpanel

2. I need a way to load a specific tab when the page loads for the first time.
This will be done programmatically based on certain rules.
Solution: wnd.getFellow("A1_2").setSelected(true);

Please note that I have multi level tabs, which means that I might need to load
A1_2 when the page loads. (Level 1: Tab1 Level 2: Tab2) To achieve this, I do 'setSelected(true)' for all the tabs from the top level as well. In this case,
A1 and then A1_2
(although this does not appear in the code above:
wnd.getFellow("A1").setSelected(true); can be attahced before:
wnd.getFellow("A1_2").setSelected(true);
but the result is the same).

My problem is that both requirements 1 and 2 cannot be achieved collectively with the solutions mentioned above. So is there any way by which I can avoid loading of all the tabs at the same time and also allow dynamic loading of a 2nd level tab on page load?

/abhigyan

link publish delete flag offensive edit

answered 2007-08-23 01:16:16 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4479802

By: henrichen

1. fulfill is triggered by the specified "event". And until then the associated components are created.

2. The onCreate() that fire the "event" is triggered later after the page is completely loaded. (i.e. when getFellow("A1_2") in zscript is called when loading the page, the onCreate() is not called yet.) So wnd.getFellow("A1_2") will give you the error message since that A1_2 component has not been created yet.

3. Try this. Remove the last zscript and add a button like following:

...
<button label="Select A1_2">
<attribute name="onClick">
wnd.getFellow("A1_2").setSelected(true);
</attribute>
</button>
</window>
</zk>

When you press the button, things go as what you want because the component is already created.

If you simply want the "default" selection is on A1_2, just change the onCreate and selected accordingly:

...
<tabbox width="100%" id="tabI">
<attribute name="onCreate">
Events.postEvent("onSelect",A1_2,null);
</attribute>
<tabs>
<tab label="1.1" id="A1_1" />
<tab label="1.2" id="A1_2" selected="true"/>
</tabs>
...


/henri

link publish delete flag offensive edit

answered 2007-08-23 01:43:03 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4479824

By: henrichen

Or you can do following. When onCreate is called, the A1_2 component is already created.

<tabbox width="100%" id="tabI">
<attribute name="onCreate">
A1_2.setSelected(true);
</attribute>

/henri


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: 2007-08-21 14:05:11 +0800

Seen: 1,248 times

Last updated: Aug 23 '07

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