Basically, In any application for UI we have access control for various element.
Say, I have a button to be visible to PM
<logic equal=pm>
TheButton
</logic equal>
<logic NotEqual=pm>
TheButton=disabled
</logic NotEqual>
Now say there is one more condition say developer has different access. Since there is no AND in tags...We do as
<logic equal=pm>
TheButton
</logic equal>
<logic NotEqual=pm>
TheButton=disabled
</logic NotEqual>
<logic equal=developer>
TheButton
</logic equal>
<logic NotEqual=developer>
TheButton=disabled
</logic NotEqual>
So here code keeps increasing and access control is all f开发者_如何学Cragmented.
In struts2, for each method inside Action class, I can create Custom Annotation and check access control. Like @Role=pm,developer
How to do it in jsp ? such that i can write.
<button name=Thebutton access="pm,developer" >
Or something like that.
You could write a method in your controller saying "getElements()" which would return back only permitted elements. Feel free to even write simpler actions returning back individual elements or blank string so that your main.jsp remains clean.
精彩评论