• 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

Struts with WSAD 5.0 question

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question about configuring Struts application.
I have 3 jsp�s: List.jsp, Edit.jsp, Next.jsp and I need to populate Edit.jsp with values from db.
I wrote code to set properties of EditForm.java in �perform� method of EditAction.java.
But I cannot find a way how to configure that. I need that EditAction was invoked before Edit.jsp is displayed, so I forward from ListAction to EditAction.
Then if I write on Edit.jsp < html:form action="edit.do">
It�s okay but how can I redirect to Next.jsp?
If I put on Edit.jsp < html:form action="next.do">
I get an error:
E SRVE0026E: [Servlet Error]-[No getter method available for property country for bean under name org.apache.struts.taglib.html.BEAN]:
Where property name is always the name of first control on Edit.jsp page
Thanks in advance
 
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like you might have 2 separate issues. First, here's how your flow should probably look:
->listAction.do
-> forward to list.jsp
-> user clicks edit link to editAction.do
-> editAction.do loads fields
-> forward to edit.jsp
rather than what sounds like
->listAction.do
-> forward to editAction.do
-> forward to edit.jsp
(Which will pass the list bean to edit, which wil not have the right fields--voila, the problem you're seeing.)
So the key is in editAction, knowing whether to process the request as an actual edit, or to process it as the setup for editing.
The easy way to do this is with a request parameter. On your edit form, set your action to be
<form action="/editAction.do?update=true">
and in your code check for that edit action.
[ February 11, 2003: Message edited by: David Hibbs ]
 
Jenny Kalinina
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
Thanks for your response.
I've changed the flow as you said, but still have the same problem, since I need to set action on my list.jsp to < html:form action="edit.do"> so that when user submit list.jsp it goes to editAction.do which in its turn forwards to edit.jsp.
Looks like I never can set form action for action that is not related with given *.jsp (like action for list.jsp can be set only to list.do etc.)
Or I did somethig wrong?
Some text disappear at the bottom of your reply
Thanks in advance
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I edited my post since I goofed on getting the form to show.
 
Jenny Kalinina
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David,
Could you please give more details since I am new to Struts and in tutorials there are only very simple examples.
When you say �user clicks edit link to editAction.do� I understand that code on list.jsp should be �< html:form action="editAction.do">� and then
I load data in editAction.java and forward to edit.jsp where I put:
< form action="editAction.do?Update=true">. I think I did something wrong because when it starts opening page edit.jsp I have an error:
E SRVE0026E: [Servlet Error]-[Cannot find bean org.apache.struts.taglib.html.BEAN in scope null]: javax.servlet.jsp.JspException
Also I do not understand where in my code I have to check for edit action and what to check if it is always like �update=true�
Sorry for silly questions but I am not familiar with that.
Thanks very much in advance
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David,
When you say �user clicks edit link to editAction.do� I understand that code on list.jsp should be �< html:form action="editAction.do">�

Actually, no, the link on list.jsp is something more like
<html:link href="editAction.do" paramId="listItem" paramName="myListBean" paramProperty="myProperty">Click here to edit</html:link>
where you have a bean on your list.jsp named "myListBean" that has a property "myProperty" which is the key to the object you want to edit.
Anyway, the key is that list.jsp need not be a form (and you'll probably find it easier to get it to work if it's not).
Also I do not understand where in my code I have to check for edit action and what to check if it is always like �update=true�
Sorry for silly questions but I am not familiar with that.
Thanks very much in advance
You check for the update parameter in your Action class implementation for editAction.do. i.e. if you have
<action path="/editAction" type="com.mycompany.actions.EditAction"/>
in your struts-config.xml, it goes in your class com.mycompany.actions.EditAction in perform.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic