• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reduex: Re-use a tile w/ different FormBeans.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reduex:

Any ideas on how to re-use a tile in the context of different form beans?

I have two subclasses of an abstract Form and have registered in Struts-config as say, "FormBean1" and "FormBean2". I have separate action mappings for each of these.

I want to then create a tile (say using "commonTile.jsp") that has the common attributes (the ones from the parent Form class). How do I then re-use this tile with either of these FormBeans, considering that their names are different?

In other words, I may have "formBean1.jsp" that works with "FormBean1" and I want to insert the "commonTile.jsp", using <tile:insert>, into this "formBean1.jsp". And also similarly into "formBean2.jsp" that works with "FormBean2". What bean name do I use w/ the tags that are in "commonTile.jsp"?
 
Vimal Agarwal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pretty straight forward actually.

I "tiles ut" an attribute as part of the insert in the "formBean1.jsp" and passed in the formbean name, say "FormBean1". Then I imported this attribute in the "commonTile.jsp" and used that as the bean to refer the tag properties to.

e.g.
------------------------
Code in formBean1.jsp:

<tiles:insert definition="testInsertTile">
<tiles ut name="formBeanForCommonTile" beanName="FormBean1" />
</tiles:insert>
------------------------
Code in commonTile.jsp:

<tiles:importAttribute name="formBeanForCommonTile" />

<bean:write name="formBeanForCommonTile" property="anAttrInForm" />
------------------------

Worked out just fine.
 
Vimal Agarwal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The above post was supposed to show the put attribute of tiles being used, not the emoticon.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic