forcing to use custom-attribute

asked 2012-12-19 11:03:05 +0800

frant gravatar image frant
54 1

Hello again,

we're using custom-attributes in each zul to check wether the user has the permission (role) to use this page, like this:

<custom-attributes menuName="person.persons (login)" 
					   roles="ROLE_DEVEL, ROLE_ADMIN, ROLE_BO" />

Now I try to force the usage of this custom-attribute -
So everytime when I create a zul file (with some exceptions),
there has to be a custom-attribute with roles in it, otherwise there should be an error-message
given when I try to open the zul without declaring these custom attributes.
Or is there even a way to throw an error into console?

How and where could I do this? (security-config.xml?)

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-12-19 13:23:53 +0800

frant gravatar image frant
54 1

...help? anyone? :S

Of course I could easily write in every zul-file simply the code from above with the respective roles etc.
But I am not the only one working on this project, and there are some functions that some people aren't allowed to see/execute.
If a devel forgot by accident to add these custom-attributes with roles, you know.. wouldn't be funny.

please help and a big Thank You in advance!

link publish delete flag offensive edit

answered 2012-12-19 15:09:44 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6

To achieve this, we used Spring Security.
So you can map each resource path to a list of roles and that's it.

if you can't adopt Spring Security, you can self implement something similiar with System-level Initiator following this:


link publish delete flag offensive edit

answered 2012-12-19 15:23:53 +0800

frant gravatar image frant
54 1

We're using it as well... but I'm a newbie, so I didn't knew how to solve this :/ (practical semester,studying IT)
I found what I was looking for!
Since the custom attributes belongs to a window, I just needed to call a simple windowId.getAttribute() in the Controller for accessing these.
But this would have been too much work - I had to check it that way in EVERY controller!
And checking it in the superclasses would only work if the method in the superclass would be called as well..
phew, but I'm traversing now with a unit test in order to check the war file if it has been built correctly.

Thank you very, very much, gganassin!
Cheers :)

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




Asked: 2012-12-19 11:03:05 +0800

Seen: 44 times

Last updated: Dec 19 '12

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