• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

problem with struts2...

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 https://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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, i will try that, thanks again to you!!
 
hans meiser
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
We noticed he had no friends. So we gave him this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic