File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts - Tiles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts - Tiles" Watch "Struts - Tiles" New topic
Author

Struts - Tiles

Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
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


Sree Jag<br />SCJP 1.4
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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.)


A good workman is known by his tools.
Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
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

Joined: Oct 14, 2003
Posts: 77
and also the same error comes up with the JSP in which i have html:form
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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

Joined: Oct 14, 2003
Posts: 77
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

Joined: Feb 05, 2003
Posts: 4727

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

Joined: Oct 14, 2003
Posts: 77
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

Joined: Feb 05, 2003
Posts: 4727

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

Joined: Jun 07, 2004
Posts: 1
Marc, I guess you have to look at Seshu's java bean too!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts - Tiles