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 question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts question" Watch "Struts question" New topic
Author

Struts question

Chris Spierings
Greenhorn

Joined: Mar 29, 2001
Posts: 25
I've been asked to pick up after someone who has moved on in a project and he has done somethings a bit differently than I might have with Struts. On the JSP he is using a link to call a loadaction which is just fine however the value of the row selected in a list box isn't making it into the form and as a consequence we're getting a null pointer down the road a bit.
When I use a button on the jsp that I've done the updating of the form for the page happens automatically for me. I'd sure appreciate some pointers on how to proceed. I don't have the luxury of changing the jsp to use a button. At least not without a huge fight with the client.
Thanks
Chris spierings@mailbag.com
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Originally posted by Chris Spierings:
On the JSP he is using a link to call a loadaction ...
Chris spierings@mailbag.com

Do you mean he has coded the loadaction inside an anchor tag? Like <A HREF=...>? If so, then you might want to consider two possible alternatives.
1) Rplace the <A ...> element with an <INPUT TYPE="IMAGE"...> or <INPUT TYPE="SUBMIT"...>
or
2) Use JavaScript onclick() to make the form submit when the <A ...> element is clicked.
smercmu
Greenhorn

Joined: Feb 25, 2002
Posts: 20
I'm not an expert at struts yet, but hopefully this might help you track things down... Was the previous developer using an ActionForm or just the action? Sounds like there might be a problem in how the ActionForm object is being used. Is the drop down box using the struts-html tag library? If so, make sure it references the ActionForm.
Chris Spierings
Greenhorn

Joined: Mar 29, 2001
Posts: 25
Thanks for the suggestions. I'm going to see if I can work with the usability folks to get something other than a link in place. Someone higher up the food chain has decided that javascript is a no/no so I'm not sure I've got much of an alternative.
Thanks again
Chris
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5288
    
  10

If you have no luck with the usability people and must use a link, and if using JavaScript is out, then the only choice I think you have would be to include the value in the link as a parameter via a JSP expression, like so:
<a href="/myaction.do?theparam=<%= some expression %>">click here</a>


Junilu - [How to Ask Questions] [How to Answer Questions]
Ted Husted
Author
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
Technically, there isn't a great deal of difference between a form button and link. The Struts html:link tag does accept dynamic parameters, either a single property or in a map. I can't be more specific without knowing more about the page you're working on.
HTH, Ted.


<a href="http://husted.com/struts/book.html" target="_blank" rel="nofollow">Struts in Action</a>
 
 
subject: Struts question