0

Need help with switch and menu...

asked 2008-12-04 10:50:46 +0800

Eric1609 gravatar image Eric1609
9

Hi I have a problem and I do not find the mistake...

First of all don't blame me for my english, and my not that professional coding skills.

However I created a menu using menubar etc. the onClick event is always: onClick="sel_item(self.label)"

The function:

<zscript>
sel_item(self) {
menu_sel = self;
}  
</zscript>

I even tested with an alert message and the correct value I am expecting is shown. But here is the core problem:
After setting the variable menu_sel - I included a switch, that should normally load the correct pages...

<zk switch="${menu_sel}">
	<zk case="Menuentry">
		<include src="/Main/Menu1/Menuentry.zul"/>
	</zk>
	<zk>
		<include src="/Main/home.zul"/>
	</zk>
</zk>

It just does not work... It always loads the home site, but not the correct page I selected in the menu.

Thanks in advance for your help & advice.
Best regards,
Eric

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2008-12-04 14:37:34 +0800

ziccardi gravatar image ziccardi
321 7

When you call the sel_item, the page has been already rendered and the switch already evaluated, so, even if you change the
menu_sel value, nothing happens.

Try something like this:

<zk>
   <include id="content" src="/Main/home.zul />

   <zscript>
       void sel_item(String item)
       {
           if (item.equals("Menuentry"))
              content.setSrc("/Main/Menu1/Menuentry.zul");
           else
              content.setSrc("/Main/home.zul");
       }

   </zscript>

</zk>

link publish delete flag offensive edit

answered 2008-12-05 09:38:54 +0800

Eric1609 gravatar image Eric1609
9

Great thank you very much for your help.
Now everything works perfectly

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: 2008-12-04 10:50:46 +0800

Seen: 148 times

Last updated: Dec 05 '08

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