This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes How to use Bean:define Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to use Bean:define" Watch "How to use Bean:define" New topic
Author

How to use Bean:define

Muni Jampana
Greenhorn

Joined: May 27, 2007
Posts: 9
Hello,
I am trying to build a search page for movie webite.. I am able to show the movie names when I search as links.
My requirment is when I clicked on the movie name I should be able to view the movie details. For which I used bean efine tag.

<logic:iterate id="result" name="searchform" property="arl">
<bean efine id="paramId" name="result" property="movie_id" />

<%params.put("passId",pageContext.findAttribute("paramId"));
pageContext.setAttribute("params",params);%>

<html:link action="/DisplayMovieDetails" name="params">
<bean:write name="result" property="movie_name" /></html:link>
</logic:iterate>

arl is my arraylist.
searchform is my formbean.
When I say Object requestId = request.getParameter("passId");
I am not getting the value:
my struts config is
<action path="/DisplayMovieDetails" type="magfa.actions.DisplayMovieDetailsAction" name="moviedetailsform" scope="request" input="/SearchResults.jsp">
<forward name="success" path="/MovieDetails.jsp">
</forward>

Please tell me the error in this. If possible help me doing this in anyother form.
Thanks
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Are you just passing one parameter? Looks like it is named "passId". If you just need to pass this one parameter on the url then you should be able to use this code:


- Brent
Muni Jampana
Greenhorn

Joined: May 27, 2007
Posts: 9
Thank you very much Brent it is working..
But I have a doubt.

When do we use bean efine? In which scenario?
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Here is a link to the docs for the bean efine tag (the 1.1 version of the docs):
http://struts.apache.org/1.1/userGuide/struts-bean.html#define

The bean efine tag is a way of defining a variable that can then be used in some scriplet code.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use Bean:define
 
Similar Threads
No getter method?
does html link provide
problem with action mapping
Using both struts html:link and bean:write error
html:link in logic:iterate