struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sharath karnati <karna...@yahoo.com>
Subject Getting Struts2 Action class values.
Date Thu, 29 Oct 2009 20:28:03 GMT
Hi All,
 
    Say I'm having below submit.jsp file.
 
<s:form name="Inquiry" action="inquiry" method="POST">
<table>   
<tr>
<td>
First Name: 
</td>
<td width="33%">
<s:textfield key="first_name" maxlength="50" size="25"/> 
</td>
<td width="15%">
Last Name: 
</td>
<td width="35%">
<s:textfield key="last_name" maxlength="50" size="25"/> 
</td>
</tr>
<tr>
<td>   
<s:submit value="Submit Report" type="submit" cssClass="ibutton" />
</td>
</tr>
</table>
<s:form>
 
 
on submit this form it will invoke InquiryAction
 
public class InquiryAction extends ActionSupport implements ParameterAware
{
 
    
private String first_name;
private String last_name;
private Map parameters;
 
public String getFirst_name() {
   return first_name;
}
 

public void setFirst_name(String first_name) {
   this.first_name = first_name;
}
 
 

public String getLast_name() {
   return last_name;
}
 
 

public void setLast_name(String last_name) {
   this.last_name = last_name;
 }
 
public Map getParameters() {
return parameters;
}

public void setParameters(Map parameters) {
this.parameters = parameters;
}
 
public String execute() throws Exception 
{
 
   System.out.println("Inside execute first_name:"+getFirst_name() + " , Last_name:"+ getLast_name());
   
Map parameters1 = ActionContext.getContext().getParameters();
 
 
Iterator it = parameters1.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry pairs = (Map.Entry)it.next();
   System.out.println(pairs.getKey() + " = " + pairs.getValue());
}
 
  processInputValues(parameters);
 
}//end of execute
 
   
 
}//End of InquiryAction 
 
 
In InquiryAction execute method, it is prining 'first name' and 'last name' given in submit.jsp,
but when I print parameters/parameters1 it is not printing any values.
 
What I need is that, the Action will have variables with setters & getters I'd like to
pass all the variable values for this action to another method(util program). It should prepare
Map with key and value pair for all the variables defined in Action class.
 
Is there anyway to get valuestack which will hold all the values for Action class?
 
For a sample, I provided 2 properities in Action class but it may have more properties and
it may include another beans (pojo) references.
 
Thanks in advance.
 
Regards,
Sharath. 


      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message