-
FEATURED COMPONENTS
First time here? Check out the FAQ!
What's the best/easiest way of showing/hiding components in a ZUL page based upon a Spring Security authentication?
I can't find any examples of how to manage this.
I followed that earlier example of building a custom tag library. Now I have a problem with the 'if' attribute not being re-evaluated after a user logs in.
Here's a my processing sequence...
* The web app starts, not requiring authentication, with all users having a 'ROLE_GUEST' authority
* Some of the toolbar and tree based menu options are hidden.
* A user then decides to login manually - the revised Spring authentication is correctly generated
* I then force an 'invalidate' on the toolbar and menu windows to force a redraw
Some of the previously hidden toolbar and tree based menu options should now appear but they are not. Is 'invalidate' the right call here?
Hmmm,
* I then force an 'invalidate' on the toolbar and menu windows to force a redraw
i don't know. You mean with invalidate() reads the zul-file new??
Try to detach() the page and create it new.
Stephan
Yep, tracing thru the code a call to 'invalidate' does not force a re-evaluation of the 'if' attributes. Is that right or a bug?
The two areas I'm trying to force a refresh of the 'if' attributes are both within windows - a toolbar window and a left side menu in the form of a tree.
Suggestions?
Hmmm, from the view of logic i mean that's right. I see the zul-file as a 'template' .
ZKoss renders all the comps with their defined attributes and ends in a ready html-page.
On server side they can hold the status of the comps.
You must move security logic to the code or recreate the page. Have you try an detach()
and createComps() ?
Stephan
I've tried two things....
a). detach and then set parent
This doesn't appear to work
b). push toolbar into different ZUL file and then use an include tag in the main ZUl file
The idea was to reload the include from the toolbar source. Yet I've hit another problem here. I use a chain of 'getFellow()' calls to find the window in which the toolbar resides. When I move the toolbar into a separate ZUL file this same 'getFellow()' approach no longer works, even if I include a new getFellow element for the 'include' tag.
But there again I find the whole issue of finding a component in a page very confusing. The doc examples aren't that helpful. I'd appreciate an idiot level explanation/example of how...
* to find from a given page a nominated 'include' tag
* to find from a given page a nominated 'window' tag
* to find from a given page a nominated 'window' tag that is part of another ZUL source file loaded via an 'include' tag
TIA
Hmmm,
to find from a given page a nominated 'include' tag
I mean you cannot find a tag. You can find a component by it's ID.
Devout you must see all the times a picture of your page in your brain.
That's only a big xml file with a root node and many many childs and items.
And for handling this stuff easier the zk Guys makes the great composer.
If you have all times work with this composers (autowire comps/id's) and overhanded
controllers for pieces of your page than it's easy to access all components by name(ID).
Stephan
Yes - I mean finding a window component by its ID. The same 'getFellow() chain of component links doesn't work if the logical page is made up of some parts imported via 'include' tags.
Take the following example....
<?page id="main" title="SKAP - services" cacheable="false" language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?> <?taglib uri="/WEB-INF/tld/authentication_util.tld" prefix="auth" ?> <zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"> <borderlayout id="one_border"> <north id="two_north"> <window id="toolbarWindow" apply="com.eis.skap.toolbar.ToolbarWindowComposer">
Component aComp = getDesktop().getPage("main").getFellow("one_border").getFellow("two_north").getFellow("toolbarWindow");
<?page id="main" title="SKAP - services" cacheable="false" language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?> <?taglib uri="/WEB-INF/tld/authentication_util.tld" prefix="auth" ?> <zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"> <borderlayout id="one_border"> <north id="two_north"> <include id="three_toolbar_include" src="/views/main/toolbar_window.zul" />
Component aComp = getDesktop().getPage("main").getFellow("one_border").getFellow("two_north").getFellow("toolbarWindow"); Component aComp = getDesktop().getPage("main").getFellow("one_border").getFellow("two_north").getFellow("three_toolbar_include").getFellow("toolbarWindow");
Hmmmm,
try this:
Path.getComponent("//mainpage/win/tab1/label1").setValue("Hi, i catch you");
Stephan
Asked: 2009-03-19 09:34:19 +0800
Seen: 894 times
Last updated: Mar 27 '09