Since I can not force the processing of the tags that are generated on the fly, I chose a hack to call the functions that the container would call on the tag myself explicitly. By doing so, I explicitly forced the tag-lifecycle.
I am not claiming this is a neat solution, but the best of the workable solutions I had. Hope the following code helps: private static void generateMenuItem(User user, Resource resource, PageContext ctx, Tag parent) { if (resource ==null) return ; //Playing the container for the tag: "<layout:menuItem key='"+resource.getName()+"' link='"+resource.getName()+"'>"); Tag tag = null; if (StringUtils.isNotEmpty(resource.getMenuDisplayName()) && !(resource.isDenied())) { tag = new MenuItemTag2(); tag.setPageContext(ctx); tag.setParent(parent); ((MenuItemTag2)tag).setKey(resource.getMenuDisplayName()); if (StringUtils.isNotEmpty(resource.getMenuLink())) ((MenuItemTag2)tag).setLink(resource.getMenuLink()); try { tag.doStartTag(); } catch (JspException e) { e.printStackTrace(); //TODO: Log this error in the appropriate logger } } else { tag=parent; //for the children of this tag, the parent will have to be set to the parent of this tag. } for(Iterator itr = resource.getSubResources().iterator(); itr.hasNext();) { generateMenuItem(user,(Resource) itr.next(),ctx,tag); } if (StringUtils.isNotEmpty(resource.getMenuDisplayName()) && !(resource.isDenied())) { //Playing the container for the tag: ("</layout:menuItem>"); try { tag.doEndTag(); } catch (JspException e) { e.printStackTrace(); } tag.release(); } } On 1/30/06, Kai Mai <[EMAIL PROTECTED]> wrote: > Raghu, > can you be more specific about your solution? how about giving some coding > examples? > > Thanks. > Kai > > On 1/27/06, Raghu Kanchustambham <[EMAIL PROTECTED]> wrote: > > > > Hi, > > I solved the problem by "playing the container". > > > > I called the tag functions that the container would have called in the > > same sequence. This surely is a hack, but works for me right now. > > > > If you guys have a better way to solve this issue, I would be glad to hear > > it. > > > > Regards, > > Raghu > > > > > > On 1/25/06, Raghu Kanchustambham <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I am trying to generate a *dynamic* menu. > > > I have a regular 'java' function which spits out menu tags (struts > > > layout taglib related). > > > The intention is to use Sitemesh to create the menu depending on the > > > access permissions of the logged in user without any "dirty coding" in > > > JSP's. > > > > > > <%=Resource.generateMenu(DataAccessManager.getResourceById(-1))%> > > > > > > Resource.generateMenu recursively calls itself till it generates a > > > string of menu tags depending on access permissions. Ignore the fact > > > that my JSP is directly calling a function in my dataacess layer! ;-) > > > Will fix it once I get this to work:-) > > > > > > > > > I am stuck with the following problem. I do not know how to force the > > > interpretation of the string of tags generated. What is happening (as > > > expected) is that the tags just pass to the browser as they are with > > > OUT getting processed. > > > > > > A "view source" on my browser shows the following: > > > > > > <body> > > > <table width="100%"> > > > <tr width="100%"> > > > > > > <!-- The output of generateMenu function starts here --> > > > <layout:dynMenu config='MainMenu' left='10' top='10'> > > > <layout:menuItem key='All' link='All'> > > > <layout:menuItem key='Reports' > > > link='Reports'></layout:menuItem> > > > <layout:menuItem key='Student' link='Student'> > > > <layout:menuItem key='Enrollment' > > > link='Enrollment'></layout:menuItem> > > > <layout:menuItem key='Enquiry' > > > link='Enquiry'></layout:menuItem> > > > <layout:menuItem key='Search' > > > link='Search'></layout:menuItem> > > > </layout:menuItem> > > > <layout:menuItem key='Management' > > link='Management'> > > > <layout:menuItem key='Location' > > > link='Location'></layout:menuItem> > > > <layout:menuItem key='Centre' > > > link='Centre'></layout:menuItem> > > > <layout:menuItem key='Course' > > > link='Course'></layout:menuItem> > > > </layout:menuItem> > > > </layout:menuItem> > > > </layout:dynMenu> > > > etc..... > > > > > > > > > > > > Note that these tags are generated as a result of the generateMenu > > > function and are NOT getting processed further on the server side > > > before they > > > are pushed on to the browser. I believe JSP does only ONE pass > > > parsing. How do I circumvent this problem and get my tags to be > > > processed before they leave the server? > > > > > > Thanks. > > > Regards, > > > Raghu > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]