Here is my form
<s:form action="changeStatus">
<s:div class="table">
<s:textfield name="custId" label="CUSTOMER ID" />
<s:textfield name="lifewardsCard" label="LIFE WARDS CARD NUMBER"
size="20" />
<s:textfield name="clientNo" label="CLIENT NUMBER" />
<s:textfield name="custName" label="CUSTOMER NAME" />
<s:textfield name="cardExpiryDate" label="CARD EXPIRY DATE(MMYYYY)" />
<s:select name="status" label="CARD STATUS"
list="#{'1':'Active', '2':'Inactive'}" />
<tr>
<td><s:submit value="search" theme="simple" /></td>
<td><s:submit value="save" theme="simple" /></td>
<td><s:submit type="button" theme="simple"
onclick="clear();return false;" value="clear" /></td>
</tr>
</s:div>
</s:form>
user will input the field custID and clicks search button I am able to get the values from database and show them on the page but what I wanted to do is after displaying the data he can edit the data and should be able to save the data by clicking save button. here's my xml configuration
<action name="changeStatus" class="com.struts.lifewardscard.ChangeAction">
<result name="input">ChangeCardStatus.jsp</result>
<result name="success">ChangeCardStatus.jsp</result>
</action>
and here is my action class
public class ChangeAction extends ActionSupport implements ModelDriven {
CardStatusForm cardSform=new CardStatusForm();
public String execute() throws Exception{
String clientId=null;
HttpServletRequest request = ServletActionContext.getRequest();
getCardHolderDetails();
return "success";
}
private void getCardHolderDetails() {
Connection c = null;
Boolean empty = true;
DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
// Format date into output format
DateFormat outputFormat = new SimpleDateFormat("dd-MMM-yyyy");
try {
c = Conexion.getConnection();
CallableStatement cst = c
.prepareCall("{call P_GET_CARD_DETAIILS(?,?)}");
cst.setString(1, cardSform.getCustId());
cst.registerOutParameter(2, OracleTypes.CURSOR);
cst.executeUpdate();
ResultSet rs = (ResultSet) cst.getObject(2);
while (rs.next()) {
cardSform.setLifewardsCard(rs.getString(1));
cardSform.setClientNo(rs.getString(2));
if(rs.getString(3).equalsIgnoreCase("active"))
{
cardSform.setStatus(1);
}else
{
cardSform.setStatus(2);
}
cardSform.setCustName(rs.getString(4));
cardSform.setCardExpiryDate(rs.getString(5));
System.out.println(inputFormat.parse(rs.getString(6)));
empty = false;
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public Object getModel() {
// TODO Auto-generated method stub
return cardSform;
}
}
even though I can write a method that can save the data in action class I dont find a way to call that method with out calling the other method getCardHolderDetails()
.