You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alex <bi...@creatiweb.com> on 2005/12/30 18:45:20 UTC

How to pass readonly data through validate?

Hi,

I'm creating a web form that displays both editable and readonly data 
at the same time. I am preparing all data in my Action.execute() 
method and populate the form there, which works great. Unless I am 
using ActionForm.validate(), because in case of failure the execute() 
method is bypassed and I am missing the readonly part of my page 
contents. One way so far is to replicate parts of the Action code in 
the validate() method, but this seems verry ugly. 

This is what I have so far in pseudo-code:

-> User calls URL with record ID parameters to get an editable form

+ ActionForm.validate(): Returns early because this is not a 
submission yet
+ Action.execute(): Interprets the ID parameter, fetches EJBs from it, 
does some magic based on the caller identity, populates the form with 
both editable and readonly content. Forwards to JSP.
+ JSP: Displays both editable and readonly content.

-> User fills in the form and submits; some data is in invalid format

+ ActionForm is populated based on parameters
+ ActionForm.validate(): Because it's a submission, now the form is 
validated. The invalid format is detected and an ActionErrors object 
populated. Now, since the execute() method will be bypassed, we have 
to fetch the EJB, do the magic and populate the readonly content right 
here (Ugly, ugly, ugly). 
+ JSP: Displays messages about validation failures along with data 
submitted so far and the readonly content. 


I'd appreciate if you could give me tips how to best populate the 
readonly content to handle both initial display and validation failure.

Thanks,
Alex

-- 


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


Re: How to pass readonly data through validate?

Posted by David Evans <ds...@berndtgroup.net>.
You will probably find this useful, it covers a variety of options to
solve the problem.

http://www.reumann.net/struts/articles/request_lists.jsp

On Fri, 2005-12-30 at 12:45 -0500, Alex wrote:
> Hi,
> 
> I'm creating a web form that displays both editable and readonly data 
> at the same time. I am preparing all data in my Action.execute() 
> method and populate the form there, which works great. Unless I am 
> using ActionForm.validate(), because in case of failure the execute() 
> method is bypassed and I am missing the readonly part of my page 
> contents. One way so far is to replicate parts of the Action code in 
> the validate() method, but this seems verry ugly. 
> 
> This is what I have so far in pseudo-code:
> 
> -> User calls URL with record ID parameters to get an editable form
> 
> + ActionForm.validate(): Returns early because this is not a 
> submission yet
> + Action.execute(): Interprets the ID parameter, fetches EJBs from it, 
> does some magic based on the caller identity, populates the form with 
> both editable and readonly content. Forwards to JSP.
> + JSP: Displays both editable and readonly content.
> 
> -> User fills in the form and submits; some data is in invalid format
> 
> + ActionForm is populated based on parameters
> + ActionForm.validate(): Because it's a submission, now the form is 
> validated. The invalid format is detected and an ActionErrors object 
> populated. Now, since the execute() method will be bypassed, we have 
> to fetch the EJB, do the magic and populate the readonly content right 
> here (Ugly, ugly, ugly). 
> + JSP: Displays messages about validation failures along with data 
> submitted so far and the readonly content. 
> 
> 
> I'd appreciate if you could give me tips how to best populate the 
> readonly content to handle both initial display and validation failure.
> 
> Thanks,
> Alex
> 


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