You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christophe Thiebaud <ct...@stylo.it> on 2000/09/19 13:52:38 UTC

focus

Hi,

The following feature is fairly common and I cannot find an easy way to have is
handled by struts. Forgive me if it had been precedently answered.

I have a hefty struts:form full of input fields
the validate function of my associate Form.java is impressive.
in case the validate fails,  to be nice to the user, I want the focus to be
set to the wrong field

Is there any solution other than writing my own form tag ?

Christophe

Re: focus

Posted by Christophe Thiebaud <ct...@stylo.it>.
On Tue, 19 Sep 2000, you wrote:
> Hi,
> 
> The following feature is fairly common and I cannot find an easy way to have is
> handled by struts. Forgive me if it had been precedently answered.
> 
> I have a hefty struts:form full of input fields
> the validate function of my associate Form.java is impressive.
> in case the validate fails,  to be nice to the user, I want the focus to be
> set to the wrong field
> 
> Is there any solution other than writing my own form tag ?
> 

In the mean time I found a simple solution.

I have added a property get/setFocus in my fooForm.java class which holds the
name of the HTML input field

the validate function can set it.

inside my jsp. the struts:form tag includes some java:
 <struts:form   action="foo.do"
                    name="fooForm"
                    focus="<%= fooForm.getFocus() %>"
                    type="FooForm">

seems to work

thanks Christophe


RE: wizard

Posted by "Ludwig, Pat" <pl...@silverstream.com>.
Christophe,
	could you not have a single action form manage all the form fields for
all of your wizard pages?

regards,
Pat Ludwig

> -----Original Message-----
> From: Christophe Thiebaud [mailto:cthiebaud@stylo.it]
> Sent: Friday, September 22, 2000 5:52 AM
> To: struts-user@jakarta.apache.org
> Subject: wizard
> 
> 
> I am doing a wizard-like series of jsp.
> 
> BTW, I have seen something like "provide an example of wizard" on
> a to-do list. Is there anything such as this out there? If 
> not I would be glad
> to contribute.
> 
> I have a problem with the validate function that the 
> ActionServlet triggers
> even when I am doing a "go to the previous page" move.
> 
> Obviously, when the user needs to correct or read a field in 
> the previous page
> he should not be force to fill the current page.
> 
> one solution whould be to move the controls in the Action, 
> but that defeats the
> nice structure of struts.
> 
> Is there a mean to make the validation conditional in the 
> ActionServlet ?
> 
> Christophe

wizard

Posted by Christophe Thiebaud <ct...@stylo.it>.
I am doing a wizard-like series of jsp.

BTW, I have seen something like "provide an example of wizard" on
a to-do list. Is there anything such as this out there? If not I would be glad
to contribute.

I have a problem with the validate function that the ActionServlet triggers
even when I am doing a "go to the previous page" move.

Obviously, when the user needs to correct or read a field in the previous page
he should not be force to fill the current page.

one solution whould be to move the controls in the Action, but that defeats the
nice structure of struts.

Is there a mean to make the validation conditional in the ActionServlet ?

Christophe


Re: focus

Posted by Christophe Thiebaud <ct...@stylo.it>.
as a corollary to the input focus, I would like to implement another
fairly common feature : the prompt of the incorrect input field is marked to
enhance its visibility, either by changing its color or by adding a red asterisk.

I already use the <struts:message> tag to produce the text in the html

I also use style sheets.

Again, I cannot find a simple solution outside of writing my own tag.

any suggestions ?

Christophe

On Tue, 19 Sep 2000, you wrote:
> I think the solution you came up with (using your own "focus" property) is pretty
> clever, and looks like a recommended way to do this.  The only thing you will want to
> be sure of is to initialize the "focus" property to the name of the first field on
> the screen when the form bean is first created, so that you don't get a JavaScript
> error (bad field name) the first time that the form is displayed.
> 
> Craig McClanahan
> 
> 
> > On Tue, 19 Sep 2000, you wrote:
> > > Hi,
> > >
> > > The following feature is fairly common and I cannot find an easy way to have is
> > > handled by struts. Forgive me if it had been precedently answered.
> > >
> > > I have a hefty struts:form full of input fields
> > > the validate function of my associate Form.java is impressive.
> > > in case the validate fails, to be nice to the user, I want the focus to be
> > > set to the wrong field
> > >
> > > Is there any solution other than writing my own form tag ?
> > >
> >
> > In the mean time I found a simple solution.
> >
> > I have added a property get/setFocus in my fooForm.java class which holds the
> > name of the HTML input field
> >
> > the validate function can set it.
> >
> > inside my jsp. the struts:form tag includes some java:
> > <struts:form action="foo.do"
> > name="fooForm"
> > focus="<%= fooForm.getFocus() %>"
> > type="FooForm">
> >
> > seems to work
> >
> > thanks Christophe
> 
> --
> ====================
> See you at ApacheCon Europe <http://www.apachecon.com>!
> Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
> Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
>                                     Applications to Tomcat

Re: focus

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
I think the solution you came up with (using your own "focus" property) is pretty
clever, and looks like a recommended way to do this.  The only thing you will want to
be sure of is to initialize the "focus" property to the name of the first field on
the screen when the form bean is first created, so that you don't get a JavaScript
error (bad field name) the first time that the form is displayed.

Craig McClanahan


"DONNACHA RYAN ..." wrote:

> this is Donncha Ryan not Don Ryan , try emailing , but check for correct address
>
> Date sent: Tue, 19 Sep 2000 14:33:38 +0200
> From: Christophe Thiebaud <ct...@stylo.it>
> Subject: Re: focus
> To: struts-user@jakarta.apache.org
> Send reply to: struts-user@jakarta.apache.org
>
> [ Double-click this line for list subscription options ]
>
> On Tue, 19 Sep 2000, you wrote:
> > Hi,
> >
> > The following feature is fairly common and I cannot find an easy way to have is
> > handled by struts. Forgive me if it had been precedently answered.
> >
> > I have a hefty struts:form full of input fields
> > the validate function of my associate Form.java is impressive.
> > in case the validate fails, to be nice to the user, I want the focus to be
> > set to the wrong field
> >
> > Is there any solution other than writing my own form tag ?
> >
>
> In the mean time I found a simple solution.
>
> I have added a property get/setFocus in my fooForm.java class which holds the
> name of the HTML input field
>
> the validate function can set it.
>
> inside my jsp. the struts:form tag includes some java:
> <struts:form action="foo.do"
> name="fooForm"
> focus="<%= fooForm.getFocus() %>"
> type="FooForm">
>
> seems to work
>
> thanks Christophe

--
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat