-
FEATURED COMPONENTS
First time here? Check out the FAQ!
My program separated into 2 areas, the left is menu, the right is content, then i use the template to do that. <zk> <include id="mainInclude" self="@define(content)" src="/home.zul"/> </zk>
now, i need add an authorization checking for each page, if not allow to access, then i will set the include source on the right area.
if(page.getFellowIfAny("mainInclude")!=null){
Include mainInclude = (Include)page.getFellow("mainInclude");
if(mainInclude!=null){
String p = mainInclude.getSrc();
if(p.equals("prcreate.zul")){
mainInclude.setSrc("/accessdenied.zul");
}
}
The result of program is the accessdenied.zul content and home.zul would be include at the same time, i would like to just show the accessdenied.zul content, anyone know what's the program? Thank you very much.
In my opinion the getFellowXXX methods should be avoided as much as possible. I think a better approach would be to attach a viewmodel to your view and then use something like:
<include src="@bind(myViewModel.page)"/>
However this still ties your server code too much with your zul file.
A much better approach could be:
<include src="myprotectedpage.zul" if="@load(myViewModel.canAccess)"/>
<include src="/accessdenied.zul" unless="@load(myViewModel.canAccess)"/>
This way you can freely change your zul file without affecting the Java code
Asked: 2014-01-03 08:17:01 +0800
Seen: 36 times
Last updated: Jan 16 '14