tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack <java.mail.arch...@gmail.com>
Subject Re: Can't get attribute value in JSP from tiles if using wildcard character in definition name in tiles 2.1
Date Fri, 14 Oct 2011 13:46:35 GMT
Hi Antonio,

Thanks for your reply. Here is the code snippet. I have added all jars and
imported all taglibs.

If I click the following link

<a href="user-overview.action">user Overview</a>

If I keep tiles:user:overview definition in tiles then it's working but if I
remove tiles:user:overview definition from tiles and keep tiles:*:*
definition then it's not finding pageName aatribute. Can you please help me
out in this situation?


struts.xml
-----------------------------------------------------------------------------------------------------------------
<struts>
 <package name="default" extends="struts-default, tiles-default">
  <action name="showBreadcrumb" class="x.x.BreadcrumbAction">
   <result name="success" type="tiles">tiles:breadcrumb:${pageName}</result>
  </action>
  <action name="user-*" method="{1}" class="x.x.UserAction">
   <result name="success" type="tiles">tiles:user:{1}</result>
  </action>
  <action name="dept-*" method="{1}" class="x.x.DeptAction">
   <result name="success" type="tiles">tiles:dept:{1}</result>
  </action>
 </package>
</struts>

tiles.xml
-----------------------------------------------------------------------------------------------------------------
<tiles-definitions>
 <definition name="layout" template="/layout/layout.jsp">
  <put-attribute name="title" value="My App" />
  <put-attribute name="breadcrumb" value="/layout/breadcrumb.jsp" />
  <put-attribute name="body" value="" />
  </definition>
  <definition name="tiles:breadcrumb:*" template="/breadcrumb/{1}-bc.jsp" />
 <definition name="tiles:user:overview" extends="layout">
  <put-attribute name="pageName" value="user" cascade="true" />
  <put-attribute name="body" value="/user/overview.jsp" />
 </definition>
 <definition name="tiles:*:*" extends="layout">
  <put-attribute name="pageName" value="{1}" cascade="true" />
  <put-attribute name="body" value="/{1}/{2}.jsp" />
 </definition>
</tiles-definitions>

BreadcrumbAction.java
-----------------------------------------------------------------------------------------------------------------
public class BreadcrumbAction extends ActionSupport {
 private String pageName;
 public String getPageName() { return pageName; }
 public void setPageName(String pageName) { this.pageName = pageName; }
 public String execute() throws Exception { return SUCCESS; }
}

UserAction.java
-----------------------------------------------------------------------------------------------------------------
public class UserAction extends ActionSupport {
 public String overview() throws Exception { return SUCCESS; }
 public String detail() throws Exception { return SUCCESS; }
}

layout/layout.jsp
-----------------------------------------------------------------------------------------------------------------
<html>
<head>
</head>
<body>
            <div class="wrapper innerWrapper breadCrumbs clearfix
floatLeft">
             <tiles:insertAttribute name="breadcrumb" />
            </div>
     <div class="flexCol">
  <div class="flexColMargin">
      <div class="flexColWrapper boxShadow clearfix">
   <tiles:insertAttribute name="body" />
      </div>
  </div>
     </div>
</body>
</html>

layout/breadcrumb.jsp
-----------------------------------------------------------------------------------------------------------------
<tiles:importAttribute name="pageName" ignore="true" />
<s:action name="showBreadcrumb" executeResult="true">
 <s:param name="pageName">${pageName}</s:param>
</s:action>

breadcrumb/user-bc.jsp
-----------------------------------------------------------------------------------------------------------------
<html><body>I am user bread crumb</body></html>

user/overview.jsp
-----------------------------------------------------------------------------------------------------------------
<html><body>I am user overview</body></html>


On Fri, Oct 14, 2011 at 3:38 AM, Antonio Petrelli <
antonio.petrelli@gmail.com> wrote:

> I already answered to your question. Are you correctly subscribed to the
> mailing list?
>
> 2011/10/12 Mohammad Hoque <rhoque@crosscap.com>
>
> > Hi Antonio,
> >
> >
> >
> > How can I get attribute value in JSP, where attribute value is
> > dynamically set from wildcard definition name?
> >
> >
> >
> > Thanks
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message