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 2 - Set Action Attribute From Jsp 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 "Struts 2 - Set Action Attribute From Jsp" Watch "Struts 2 - Set Action Attribute From Jsp" New topic
Author

Struts 2 - Set Action Attribute From Jsp

Ceku Camli
Greenhorn

Joined: Oct 16, 2010
Posts: 5
Hi,
I'm new to struts.
I want to complete information in a few steps. In the first step, i create a person with an id. In the second step, i have text fields and a submit button. In my action class I have an "id" attribute but can't set it.

Here is the jsp code:





How i can fix it?

Thanks!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

In my action class I have an "id" attribute but can't set it.

I don't understand this statement. When you submit the form, is the id property of your action not set to the value you you give in s:param tag?? I'm not really sure if you can use s:param tag in s:form tag. If you don't want the id value to be visible to the user, then you can use s:hidden tag...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ceku Camli
Greenhorn

Joined: Oct 16, 2010
Posts: 5
Ankit Garg wrote:
In my action class I have an "id" attribute but can't set it.

I don't understand this statement. When you submit the form, is the id property of your action not set to the value you you give in s:param tag?? I'm not really sure if you can use s:param tag in s:form tag. If you don't want the id value to be visible to the user, then you can use s:hidden tag...



In the s:form, the s:param tag does not work (unlike the s:url tag ). I was unaware of the s:hidden tag. I'll just try it.
Ceku Camli
Greenhorn

Joined: Oct 16, 2010
Posts: 5
@Ankit

Unfortunately, the property tag can not be nested in the hidden tag:

Ceku Camli
Greenhorn

Joined: Oct 16, 2010
Posts: 5
Ceku Camli wrote:@Ankit

Unfortunately, the property tag can not be nested in the hidden tag:



@myself,
try the OGNL!

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts 2 - Set Action Attribute From Jsp
 
Similar Threads
Problem With I18n feature of Struts2
struts2 textfield tag not populating with correct value from action class
struts2 autocomplete
Struts 2: Strange <s:textfield> prepopulation issue.
Struts 2: why object is removed from the ValueStack?