|
|
Re: how to use snap for design submenus [message #644784 is a reply to message #644633] |
Tue, 14 December 2010 08:56 |
Gary Lee Messages: 4 Registered: December 2010 |
Junior Member |
|
|
Thanks Dmitry,
My thought, i can use the Snap-ContextPath for split the categories as submenus.
for example
dog bundle
Snap-ContextPath: /dog
dog1 bundle
Snap-ContextPath: /dog/dog1
dog2 bundle
Snap-ContextPath: /dog/dog2
When I found the /dog/dog1 as url pattern, i will dispatch to dog1 bundle, and i will know it should display submenu under dog bundle.
However, the SnapUtil.java is substring the *ONLY* first "/" as contextPath, I can't set /dog/dog1 as contextPath.
So that, I modify the SnapUtils.determineSnapContextPath method
public static String determineSnapContextPath(HttpServletRequest request, int cnt) throws Exception {
// TODO Move to HostUtils, or similar
String result;
String includeServletPath = (String)request.getAttribute("javax.servlet.include.servlet_path");
if (includeServletPath != null) {
result = includeServletPath;
} else {
result = request.getServletPath();
}
int index = result.length();
for(int i=0; i<cnt; i++) {
index = result.lastIndexOf(PATH_ELEMENT_SEPARATOR, index);
if( index <= 0 ) {
throw new Exception("the '/' is ended ");
}
}
if (index > -1) {
result = result.substring(0, index);
}
return result;
}
and RequestRouter.findSnap
private Snap findSnap(HttpServletRequest request) {
int i = 0 ;
Snap snap = null;
try {
while(true) {
String contextPath = SnapUtils.determineSnapContextPath(request, i);
snap = this.snapRegistry.findSnapByContextPath(contextPath);
if( snap == null) {
i++;
} else {
break;
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return snap;
}
I think that this modification is not good, just for my work, the better solution is to use URL-pattern matcher to determine the contextPath with multiple "/" .
Regards
|
|
|
|
|
|
Re: how to use snap for design submenus [message #731319 is a reply to message #646036] |
Fri, 30 September 2011 16:08 |
|
Reposted form Bugzilla,
I've done some work on this and want some other peoples opinion. I see two options, we either support snaps with more than one path element in their context path as suggested here or we support nested snaps. So in this case we would attach the cat1 and cat2 snaps to the cat snap as their host making them grandchildren of the top level host.
I don't want to support both as there is too much potential for multiple snaps being about to respond to a request and there isn't a logical way to decide which snap would take priority. If we go with the grandchild approach we would place a ban on snaps with more than one path element in their context path. I prefer this approach but wanted to give people the chance to argue with me.
Chris.
------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
|
|
|
|
Re: how to use snap for design submenus [message #733624 is a reply to message #731370] |
Wed, 05 October 2011 08:45 |
|
Hi,
The Grand snap wouldn't bind to the host, it would bind to it's parent and have no idea that it's a grand snap and the host would have no idea it's got grand snaps.
------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
|
|
|
Powered by
FUDForum. Page generated in 0.45004 seconds