Re: How do we repopulate controls when validation fails?

2010-08-12 Thread Franz Wong
Thanks. It solves my problem :)

Franz

On Wed, Aug 11, 2010 at 10:11 PM, Alex Rodriguez Lopez 
alo...@flordeutopia.pt wrote:

 Don't know if this solves your problem, but maybe it helps to use the
 params-prepare-params trick, calling params interceptor twice, so you have
 your params ready before prepare().

 You have an already configured stack, the paramsPrepareParamsStack

 From struts-default.xml:

 !-- An example of the paramsPrepareParams trick. This stack
 is exactly the same as the defaultStack, except that it
 includes one extra interceptor before the prepare
 interceptor:
 the params interceptor.

 This is useful for when you wish to apply parameters
 directly
 to an object that you wish to load externally (such as a
 DAO
 or database or service layer), but can't load that object
 until at least the ID parameter has been loaded. By loading
 the parameters twice, you can retrieve the object in the
 prepare() method, allowing the second params interceptor to
 apply the values on the object. --
interceptor-stack name=paramsPrepareParamsStack
interceptor-ref name=exception/
interceptor-ref name=alias/
interceptor-ref name=i18n/
interceptor-ref name=checkbox/
interceptor-ref name=multiselect/
interceptor-ref name=params
param name=excludeParamsdojo\..*,^struts\..*/param
/interceptor-ref
interceptor-ref name=servletConfig/
interceptor-ref name=prepare/
interceptor-ref name=chain/
interceptor-ref name=modelDriven/
interceptor-ref name=fileUpload/
interceptor-ref name=staticParams/
interceptor-ref name=actionMappingParams/
interceptor-ref name=params
param name=excludeParamsdojo\..*,^struts\..*/param
/interceptor-ref
interceptor-ref name=conversionError/
interceptor-ref name=validation
param
 name=excludeMethodsinput,back,cancel,browse/param
/interceptor-ref
interceptor-ref name=workflow
param
 name=excludeMethodsinput,back,cancel,browse/param
/interceptor-ref
/interceptor-stack



  Hi,

 I have read the documentation How do we repopulate controls when
 validation
 fails [1]. I tried the action tag solution. However, when there is a
 validation error, the execute method of the action ins:action  is not
 called.

 I don't choose the Preparable solution because the parameter required is
 not
 ready in the Prepare stage. (For the first time of visit, the parameter is
 set to default.) And I don't want to call the preparation twice in both
 execute and prepare. So what is the best way to repopulate controls for
 normal case and revisit after validation error? Should I abandon to
 validate
 the input in validate method?

 Thanks.
 Franz

 [1]

 http://struts.apache.org/2.x/docs/how-do-we-repopulate-controls-when-validation-fails.html


 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




How do we repopulate controls when validation fails?

2010-08-11 Thread Franz Wong
Hi,

I have read the documentation How do we repopulate controls when validation
fails [1]. I tried the action tag solution. However, when there is a
validation error, the execute method of the action in s:action is not
called.

I don't choose the Preparable solution because the parameter required is not
ready in the Prepare stage. (For the first time of visit, the parameter is
set to default.) And I don't want to call the preparation twice in both
execute and prepare. So what is the best way to repopulate controls for
normal case and revisit after validation error? Should I abandon to validate
the input in validate method?

Thanks.
Franz

[1]
http://struts.apache.org/2.x/docs/how-do-we-repopulate-controls-when-validation-fails.html


Re: How do we repopulate controls when validation fails?

2010-08-11 Thread Alex Rodriguez Lopez
Don't know if this solves your problem, but maybe it helps to use the 
params-prepare-params trick, calling params interceptor twice, so you 
have your params ready before prepare().


You have an already configured stack, the paramsPrepareParamsStack

From struts-default.xml:

!-- An example of the paramsPrepareParams trick. This stack
 is exactly the same as the defaultStack, except that it
 includes one extra interceptor before the prepare 
interceptor:

 the params interceptor.

 This is useful for when you wish to apply parameters 
directly
 to an object that you wish to load externally (such as 
a DAO

 or database or service layer), but can't load that object
 until at least the ID parameter has been loaded. By 
loading

 the parameters twice, you can retrieve the object in the
 prepare() method, allowing the second params 
interceptor to

 apply the values on the object. --
interceptor-stack name=paramsPrepareParamsStack
interceptor-ref name=exception/
interceptor-ref name=alias/
interceptor-ref name=i18n/
interceptor-ref name=checkbox/
interceptor-ref name=multiselect/
interceptor-ref name=params
param 
name=excludeParamsdojo\..*,^struts\..*/param

/interceptor-ref
interceptor-ref name=servletConfig/
interceptor-ref name=prepare/
interceptor-ref name=chain/
interceptor-ref name=modelDriven/
interceptor-ref name=fileUpload/
interceptor-ref name=staticParams/
interceptor-ref name=actionMappingParams/
interceptor-ref name=params
param 
name=excludeParamsdojo\..*,^struts\..*/param

/interceptor-ref
interceptor-ref name=conversionError/
interceptor-ref name=validation
param 
name=excludeMethodsinput,back,cancel,browse/param

/interceptor-ref
interceptor-ref name=workflow
param 
name=excludeMethodsinput,back,cancel,browse/param

/interceptor-ref
/interceptor-stack



Hi,

I have read the documentation How do we repopulate controls when validation
fails [1]. I tried the action tag solution. However, when there is a
validation error, the execute method of the action ins:action  is not
called.

I don't choose the Preparable solution because the parameter required is not
ready in the Prepare stage. (For the first time of visit, the parameter is
set to default.) And I don't want to call the preparation twice in both
execute and prepare. So what is the best way to repopulate controls for
normal case and revisit after validation error? Should I abandon to validate
the input in validate method?

Thanks.
Franz

[1]
http://struts.apache.org/2.x/docs/how-do-we-repopulate-controls-when-validation-fails.html



-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org