This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts - Tiles

 
Sree Jag
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using tiles with Struts. I defined a layout for my site and use it accordingly. The layout has 3 jsps.

Now, if, from my action file, if i do an ActionForward, will the form bean be accessible to all the 3 jsps that i defined?

pls help,
Seshu
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
only the jsp with the html:form tag will be able to access the actionform directly through struts tags.

The other jsps can use <% ActionForm form = request.getAttribute("myForm) %> to access the actionform.

(If the form is in session scope, replace request with session in the above snippet.)
 
Sree Jag
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi marc,
this is the error i get on the browser:

"[ServletException in:/navigation/navHR.jsp] No getter method for property navigation.variables.vFontFamily of bean articlesForm' "

it doesn't say that the articlesForm is not available, it says that the property is not available.

any comments,
Seshu
 
Sree Jag
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and also the same error comes up with the JSP in which i have html:form
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's trying to call:

getNavigation().getVariables().getVFontFamily()

so your ActionForm needs a getNavigation() method
which returns an object with a getVariables() method
which returns an object with a getVFontFamily() method
which return the value to prepopulate the text input.
 
Sree Jag
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
exactly, i have all the methods in all the respective objects....but i don't understand why the JSP is not able to access the property.

-Seshu
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without more code to digest, I don't know either.

Things that would help if posted:
1) your html:form tag
2) your actionmapping from struts-config
 
Sree Jag
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my action mapping:

<action
attribute="articlesForm"
input="/articles/articles.jsp"
name="articlesForm"
path="/articles"
scope="session"
type="action.ArticlesAction"
unknown="false"
validate="true">
<forward
name="success"
path="tiles.articles"
redirect="false"
contextRelative="false" />
</action>

here's my html:form code:

<html:form action="/articles">
<bean:write name="articlesForm" property="vFontFamily"/>
<html:submit/><html:cancel/>
</html:form>

and finally here's my tiles-defs.xml code:

<tiles-definitions>
<definition name="rootLayout" path="/layouts/layout.jsp">
<put name="titleString" value="Root Layout"/>
<put name="header" value="/components/primaryHeader.jsp"/>
<put name="navigationRegular" value="/navigation/navHR.jsp"/>
<put name="panel3" value="CHANGE-ME"/>
</definition>

<definition name="tiles.articles" extends="rootLayout">
<put name="titleString" value="Articles"/>
<put name="panel3" value="/articles/articles.jsp"/>
</definition>

-Seshu
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would leave out the attribute attribute of the actionmapping in struts-config.

Also, I wouldn't put the slash in the html:form's action attribute, although it possibly isn't hurting anything.

If you're still receiving the same error, I'm having difficulties with what else could be the matter right now.
 
Gerald T Kartong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marc, I guess you have to look at Seshu's java bean too!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic