wood burning stoves 2.0*
The moose likes Struts and the fly likes problem with struts2... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem with struts2..." Watch "problem with struts2..." New topic
Author

problem with struts2...

hans meiser
Greenhorn

Joined: Dec 29, 2008
Posts: 22
Hello!

I have the followig problem:

i have this jsp page:

<body>
Sie Sind jetzt auf der CustomerTicketPage.jsp


<table>
<tr>
<s roperty value="problem.problemNumber"/>
<s ropertyvalue="problem.problemTitle" />
<s roperty value="problem.problemDescription"/>
<s roperty value="problem.problemStatus"/>
<s roperty value="problem.problemPriority"/>
<tr>

<s:iterator value="commentField">
<tr>
<td>
<s roperty value="CommentNumber"/>
<s roperty value="CommentCreationDate"/>
<s roperty value="CommentText"/>
</td>
</tr>
</s:iterator>
</table>

<s:form action="Problem_load" method="POST">
<s:submit value="Zur�ck zur �bersicht" cssClass="InputButton"/>
</s:form>

<s:form action="Add_Comment" method="POST">
<s:textarea label="Kommentar" name="CommentText"/>
<s:submit value="Kommentar hinzuf�gen" cssClass="InputButton"/>
</s:form>


</body>
</html>



in my Add_Comment Action class, i would like to use the commentText, which works perfectly if i add commentText variable to the class, and getter/setter.

But, i also need the problemNumber, but its always null if i make a variable and getters/setters. Do i need to put the problemNumber somehow into the

<s:form action="Add_Comment" method="POST">
<s:textarea label="Kommentar" name="CommentText"/>
<s:submit value="Kommentar hinzuf�gen" cssClass="InputButton"/>
</s:form>


part?

Thanks for your help!
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
Note that when the form is submitted (to the action you specified), ONLY those fields inside the open and close form tags, will be sent to the server.

I see that you have 1 set of fields, and 2 sets of forms (with their own actions).

You, of course, would not want to duplicate those fields on 2 forms in 1 single page.

Instead, you might want to have only 1 form, with the set of fields inside, and with 2 actions inside - if that is what you need.

With regards to how to do it, I will try to dig my old projects, or maybe you can ask our friend google.
hans meiser
Greenhorn

Joined: Dec 29, 2008
Posts: 22
Ok, thanks, i understand the problem now..

but if i need those values only in my second action, can i surround the whole table with the form tag?
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
Yes, that is what you have to do. That is the rule. You cannot pass data that is outside the form enclosure.

You can also try a suggestion mentioned in http://www.coderanch.com/t/58339/Struts/struts-multiple-buttons

(notice above, i am the topic starter as this was my problem also before )

But I guess you dont need to put everything in one form since only one of them needs the fields. You can just move those fields, as you mentioned, inside one of the forms.
[ January 02, 2009: Message edited by: Jesus Angeles ]
hans meiser
Greenhorn

Joined: Dec 29, 2008
Posts: 22
Ok, i will try that, thanks again to you!!
hans meiser
Greenhorn

Joined: Dec 29, 2008
Posts: 22
i have a short other question.

i know how to iterate over a vector with objects and display the values in those objects.

But now, if i have in those Objects, again an Object and i would like to display the values, how can i do that?

Vector<Object<Object.value>>
hans meiser
Greenhorn

Joined: Dec 29, 2008
Posts: 22
ok i tried it out now.. but still same error.. problemNumber is always null.


<s:form action="Add_Comment" method="POST">
<table>
<tr>
<s roperty value="problem.problemNumber"/>
<s ropertyvalue="problem.problemTitle" />
<s roperty value="problem.problemDescription"/>
<s roperty value="problem.problemStatus"/>
<s roperty value="problem.problemPriority"/>
<tr>
<s:iterator value="commentField">
<tr>
<td>
<s roperty value="CommentNumber"/>
<s roperty value="CommentCreationDate"/>
<s roperty value="CommentText"/>
</td>
</tr>
</s:iterator>
<s:textarea label="Kommentar" name="CommentText"/>
<s:submit value="Kommentar hinzuf�gen" cssClass="InputButton"/>
</table>
</s:form>

<s:form action="Problem_load" method="POST">
<s:submit value="Zur�ck zur �bersicht" cssClass="InputButton"/>
</s:form>
hans meiser
Greenhorn

Joined: Dec 29, 2008
Posts: 22
OK, its working now, i think my getter was from the wrong type...:S

But it only works once... if i add a comment to my page, and reload the same page, add another comment, then the problemNumber is null again

any idea?
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
Originally posted by hans meiser:
But it only works once... if i add a comment to my page, and reload the same page, add another comment, then the problemNumber is null again

any idea?


I didnt quite understand what you said. Would you like to explain a little bit more what you are doing and what is happening?

By the way, make sure to make a setter method also, in addition to getter method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with struts2...
 
Similar Threads
When Validation Error I Lose My Bean Value-Struts 2
Could not find a Content-Type for upload in struts2
JSF Datatable equivalent in Struts2
[Struts2] losing display only(prepopulated) values of the form if the validaiton fails
how to start an action from a link...