Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Legal to put a bean:write inside tiles-defs.xml?

 
Nadine McKenzie
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it legal to put a bean:write inside a tiles-defs.xml as follows:

<definition name="tiles.work.items" extends="tiles.mainlayout">
<put name="title">
<bean:write message="first.pageTitle" />
</put>
...

Thanks!
 
Franck Tranchant
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I never tried this but i'm pretty sure this is not legal.

If you need to insert dynamical values into tiles attributs, I would suggest you to deal with it right into the JSP using your tiles component.

BTW, why do you need this into the XML definition file ?
 
Nadine McKenzie
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The idea of tile-defs was to provide a means of by-passing creating any jsp page (with the exception the xxxLayout.jsp). The validation framework supports talking with the applicationResources.properties so it would seem logical to me that the tile-defs should have similar support.

My question then is, how can I use tile-defs and not hard code text into the tile-def for things like page titles. If there is no way to do this, then I'll put this info in the xxxLayout.jsp page.
 
Nadine McKenzie
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK I figured it out...

In the tiles-defs you put something like this

<definition name="tiles.work.items" extends="tiles.mainlayout">
<put name="title" value="label.work.items" />
<put name="body" value="/work/workItems.jsp" />
</definition>

In the layout jsp page, you make use of both the useAttribute and the bean:message as follows:

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

<tiles:useAttribute name="title" scope="request"/>

<html:html>
<head>
<title><bean:message name="title"/></title>
</head>

...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic