java - Tiles2 Wildcard not working -


i'm using spring-struts2-tiles2 in project , i'm trying use wildcard notation here remove duplicate in setup here

<definition name="home-template1" template="/web-inf/jsp/templates/template1.jsp">     <put-attribute name="banner" value="/web-inf/jsp/sitepages/banner.jsp" />     <put-attribute name="header" value="/web-inf/jsp/sitepages/header.jsp" />     <put-attribute name="body" value="/web-inf/jsp/sitepages/body.jsp" />     <put-attribute name="archive" value="/web-inf/jsp/sitepages/archive.jsp" />     <put-attribute name="footer" value="/web-inf/jsp/sitepages/footer.jsp" /> </definition> <definition name="home-template2" template="/web-inf/jsp/templates/template2.jsp">     <put-attribute name="banner" value="/web-inf/jsp/sitepages/banner.jsp" />     <put-attribute name="header" value="/web-inf/jsp/sitepages/header.jsp" />     <put-attribute name="body" value="/web-inf/jsp/sitepages/body.jsp" />     <put-attribute name="archive" value="/web-inf/jsp/sitepages/archive.jsp" />     <put-attribute name="footer" value="/web-inf/jsp/sitepages/footer.jsp" /> </definition> <definition name="home-template3" template="/web-inf/jsp/templates/template3.jsp">     <put-attribute name="banner" value="/web-inf/jsp/sitepages/banner.jsp" />     <put-attribute name="header" value="/web-inf/jsp/sitepages/header.jsp" />     <put-attribute name="body" value="/web-inf/jsp/sitepages/body.jsp" />     <put-attribute name="archive" value="/web-inf/jsp/sitepages/archive.jsp" />     <put-attribute name="footer" value="/web-inf/jsp/sitepages/footer.jsp" /> </definition> 

to

<definition name="home-*" template="/web-inf/jsp/templates/{1}.jsp">     <put-attribute name="banner" value="/web-inf/jsp/sitepages/banner.jsp" />     <put-attribute name="header" value="/web-inf/jsp/sitepages/header.jsp" />     <put-attribute name="body" value="/web-inf/jsp/sitepages/body.jsp" />     <put-attribute name="archive" value="/web-inf/jsp/sitepages/archive.jsp" />     <put-attribute name="footer" value="/web-inf/jsp/sitepages/footer.jsp" /> </definition> 

but tiles gives me following error: org.apache.tiles.definition.nosuchdefinitionexception: home-template2

below struts.xml file snipped 2 action responsible calling it

<?xml version="1.0" encoding="utf-8" ?> <!doctype struts public  "-//apache software foundation//dtd struts configuration 2.1//en"  "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <constant name="struts.devmode" value="true" /> <constant name="struts.enable.slashesinactionnames" value="true"/> <constant name="struts.mapper.alwaysselectfullnamespace" value="false"/>     <constant name="struts.action.extension" value=","/>   <package name="test" extends="struts-default" namespace="/">      <result-types>         <result-type name="tiles" class="org.apache.struts2.views.tiles.tilesresult" />     </result-types>      <action name="checkblogurl" class="checkblogurl">         <result name="success" type="redirectaction">             <param name="actionname">postpreview</param>             <param name="nextaction">${nextaction}</param>             <param name="blogsiteurl">${blogsiteurl}</param>         </result>         <result name="error">/web-inf/jsp/cmspages/index.jsp</result>     </action>      <action name="postpreview" class="blogpostaction">         <result name="success" type="tiles">${nextaction}</result>     </action>  </package> </struts> 

sample url call: mycms:8080/cms/postpreview?nextaction=home-template2&blogsiteurl=qsdcza

(note: removed extension .action/.do of struts)

also, can use wildcards in extension? eg:

<definition name="about-*" extends="home-*">     <put-attribute name="body" value="/web-inf/jsp/sitepages/about.jsp" /> </definition> 

want myself try can't make basic wildcard work :(

thank reading , appreciate help.

tiles has wildcard support in versions 2.1, 2.2.

by default, tiles 2.2 supports wildcards in definition names. wildcards lot in writing less code declare definitions.

for better usage of tiles , struts2 see tiles 2.2.2 integration.

you can use tiles definition this

<definition name="home*" template="/web-inf/jsp/templates/{1}.jsp">     <put-attribute name="banner" value="/web-inf/jsp/sitepages/banner.jsp" />     <put-attribute name="header" value="/web-inf/jsp/sitepages/header.jsp" />     <put-attribute name="body" value="/web-inf/jsp/sitepages/body.jsp" />     <put-attribute name="archive" value="/web-inf/jsp/sitepages/archive.jsp" />     <put-attribute name="footer" value="/web-inf/jsp/sitepages/footer.jsp" /> </definition> 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -