0

Hide/show components based on Spring Security authentication?

asked 2009-03-19 09:34:19 +0800

davout gravatar image davout
1435 3 18

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.

delete flag offensive retag edit

18 Replies

Sort by ยป oldest newest

answered 2009-03-19 10:10:26 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

@davout

Does your last thread this not successfull?

Stephan

link publish delete flag offensive edit

answered 2009-03-19 14:12:04 +0800

davout gravatar image davout
1435 3 18

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?

link publish delete flag offensive edit

answered 2009-03-19 14:34:09 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

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

link publish delete flag offensive edit

answered 2009-03-19 14:48:11 +0800

davout gravatar image davout
1435 3 18

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?

link publish delete flag offensive edit

answered 2009-03-19 14:59:28 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-03-19 15:00:32 +0800

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

link publish delete flag offensive edit

answered 2009-03-19 15:25:20 +0800

davout gravatar image davout
1435 3 18

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

link publish delete flag offensive edit

answered 2009-03-19 15:38:18 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

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

link publish delete flag offensive edit

answered 2009-03-19 15:43:23 +0800

davout gravatar image davout
1435 3 18

updated 2009-03-19 15:53:52 +0800

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">


You can find the 'toolbarWindow' window using...
      Component aComp = getDesktop().getPage("main").getFellow("one_border").getFellow("two_north").getFellow("toolbarWindow");


Yet, if I remove the toolbar components to a separate ZUL file, like...
<?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" />


Then I can no longer find the toolbar window using the 'getFellow' approach... I've tried both of the lines shown below...
   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");


Ideas??

link publish delete flag offensive edit

answered 2009-03-19 16:15:31 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Hmmmm,

try this:

  Path.getComponent("//mainpage/win/tab1/label1").setValue("Hi, i catch you");

Stephan

link publish delete flag offensive edit

answered 2009-03-19 16:20:50 +0800

davout gravatar image davout
1435 3 18

For this "//page/comp1/comp2" address parameter used by 'getComponent' do I have to include an id for all components in the hierarchy, or just components that have an id?

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: 2009-03-19 09:34:19 +0800

Seen: 894 times

Last updated: Mar 27 '09

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