If <s:property> if failing to show any data this can only mean the data is blank (unlikely) or the object is not available on the Value Stack.
If we look at your two use cases:
Case 1.data is posted to your application, the params are set in your action and your action is invoked. Your code in the action validates the values and sets an actionError. You return a result and the JSP is rendered including the user data and validation data. Everything is fine.

Case 2. data is posted to your application, the params are set in your action and the xml validation interceptor is invoked. The interceptor validates the values, sets an actionError and returns the input result. The JSP is rendered including the validation data but the user data is blank.

The key difference is that in case 2 your action is never invoked so the user data is never prepared/loaded for the JSP. Clearly you need some way to ensure the user data is loaded without actually invoking action. One such approach is to use the "Prepare Interceptor" [1] that is typically invoked prior to validation.

The key issue to understand is that if validation fails within the interceptor your action is instantiated but not invoked. You have to ensure that when your result calls the getter the data is available to it.

Hope that helps,
Jeromy Evans

[1] http://struts.apache.org/2.x/docs/prepare-interceptor.html
[2] http://struts.apache.org/2.x/docs/interceptors.html

dfaulcon wrote:
I have an interesting problem that I'm dealing with in regards to struts 2
validation.  I have XML validation setup throughout my application that
appear to work fine.  The validation returns the appropriate error messages
when needed.  However I have a user object that is created when a person
logs into this application.  This object contains their login, business,
etc.  When any page loads the business name and login are displayed at the
top of the page.  The code snippet below shows how I'm displaying the user
information using the property tag:
        <s:property value="user.getBusiness()"/><br />
    User: <s:property value="user.getLogin()"/> </td>

However when a user is returned to that page due to an error caught by the
validation logic the "user" information is never displayed.  In my action
form the "user" object has getter and setter methods defined.  If I validate
any data in the action class and set the actionError the error message is
displayed along with the user object information.  Is there anything I
missed why the "user" object information will now show up when   XML
validation is used?  Thanks.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to