Reputation: 596
I am working in web application using tapestry framework. I have following pages a,b,c,d and Index in my application. In Index page, check some condition and redirect to a particular page. My code,
if(null != cookieVal) {
if(cookieVal.equalsIgnoreCase("a")) {
return A.class;
} else if(cookieVal.equalsIgnoreCase("b")) {
return B.class;
} else if(cookieVal.equalsIgnoreCase("c")) {
return C.class;
} else if(cookieVal.equalsIgnoreCase("d")) {
return D.class;
}
}
Here conditions are increased if pages are increased. How can I optimize this condition check and redirect to particular page.
Upvotes: 1
Views: 1017
Reputation: 1902
Return a link created with PageRenderLinkSource service.
@Inject
private PageRenderLinkSource pageRenderLinkSource;
...
if(null != cookieVal) {
return pageRenderLinkSource.createPageRenderLink(cookieValue);
}
...
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/PageRenderLinkSource.html
Upvotes: 1