code_junkie

How to set the body URL of a tile in Struts action class?

Nov 12th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <definition name="cnmp.body.index" extends="cnmp.mainLayout" >
  2. <put name="title" value="CNM Portal" />
  3. <put name="bodytitle" value="Home" />
  4. <put name="body" value="/00-CNM_Landing.jsp" />
  5. </definition>
  6.  
  7. public class TileForwardAction extends Action
  8. {
  9. public ActionForward execute(ActionMapping mapping, ActionForm arg1,
  10. HttpServletRequest arg2, HttpServletResponse arg3) throws Exception
  11. {
  12. return mapping.findForward("theTile");
  13. }
  14. }
  15.  
  16. <action-mappings>
  17.  
  18. <action path = "/index"
  19. type = "com.bellsouth.snt.cnmp.ui.action.TileForwardAction"
  20. scope = "request"
  21. input = "cnmp.body.index"
  22. parameter= "theTile"
  23. >
  24. <forward name="theTile" path="cnmp.body.index"/>
  25. </action>
  26.  
  27. <% String destAttr=(String)request.getAttribute("dest"); %>
  28.  
  29. <jsp:include page="<%=destAttr%>" flush="true" />
  30.  
  31. request.setAttribute("dest", "landingB.jsp");
  32.  
  33. <definition
  34. name="cnmp.body.index"
  35. extends="cnmp.mainLayout"
  36. controllerClass="org.yourpackage.YourControllerClass">
  37. <put name="title" value="CNM Portal" />
  38. <put name="bodytitle" value="Home" />
  39. <put name="body" value="/00-CNM_Landing.jsp" />
  40. </definition>
  41.  
  42. public class YourControllerClasss implements Controller
  43. public void perform(ComponentContext context,
  44. HttpServletRequest request,
  45. HttpServletResponse response,
  46. ServletContext servletContext)
  47. throws ServletException, IOException {
  48.  
  49. //some logic to determine what the 'body' should be
  50.  
  51. if (service.isUp()){
  52. request.setAttribute("nameOfJSPToImport", "/jsps/import-me.jsp");
  53. }else{
  54. request.setAttribute("nameOfJSPToImport", "/jsps/import-me-instead.jsp");
  55. }
  56.  
  57. }
  58. }
  59.  
  60. <c:import url="${nameOfJSPToImport}" />
Add Comment
Please, Sign In to add comment