Hi, I am devolping a project using Struts 2 but i'm caught in this problem where i want to display the main menus as headings which are in say List1 and the submenus for all the main menus are in List 2. Now as i am using a nested iteration, it displays all the submenus under each main menu. I suppose this is quite valid as per the code i have written coz there is no way to break the inner iteration depending upon which submenus belong to the main menu. Can somebody help me with this situation. Thanks in advance
You don't send the data to the page with any information regarding which sub-menus are associated with which top-level menus; it might make more sense to use a data structure that encapsulates that information.
I finally found the solution. It has nothing to do with any of the tags. I just added one more object to the sub menu list containing the parent menu id. On the jsp page inside the first <s:iterator> tag i used an <s:if> tag to compare whether the parent id matches the parent id in each sub menu. The inner s iterator only iterates if the two matches. Otherwise it is skipped. That way all the submenus contain their parent's id and when it matches they are dispalyed under their parent. I'm pasting the code if it is of any help.