struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bhaarat Sharma <>
Subject Struts2 crud application gone wrong
Date Mon, 20 Apr 2009 19:31:45 GMT
hi guys,

i was using the example crud application ( as the skeleton for a
CRUD like module in my site.

But I've ran into a dead end.

in this sample applications the package is like this:

    <package name="default" extends="struts-default">

        <!-- Default interceptor stack. -->
        <default-interceptor-ref name="paramsPrepareParamsStack"/>

        <action name="index"
            <result name="success">/WEB-INF/jsp/employees.jsp</result>
            <!-- we don't need the full stack here -->
            <interceptor-ref name="basicStack"/>

        <action name="crud"
            <result name="success" type="redirect-action">index</result>
            <result name="input">/WEB-INF/jsp/employeeForm.jsp</result>
            <result name="error">/WEB-INF/jsp/error.jsp</result>

as you can see, they are directly calling the methods.

What I wanted to do was that when user edits something and comes back to the
listing page, they see a message on top saying id XXX has been modified.
However, I think this is not possible because a method name is mentioned in
struts.xml.  Is that correct?

to try it out I added a private member string called successString in
EmployeeAction class and created getter/setters for it.  Then in doSave and
doDelete methods I added a line that sets the member string. Then on the
listing jsp page. I simple added this line <s:property value="successString"
default="test"/>  However, it seems that the jsp page is never getting the
value from getSuccessString method.

Can someone please tell me an approach I can take to overcome this problem?

Below are the doSave and doDelete methods.

    public String doDelete() {
        setSampleString("successfully deleted");
        return SUCCESS;

    public String doSave() {
        if (employee.getEmployeeId() == null) {
        } else {
        setSampleString("successfully edited");
        return SUCCESS;

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