You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Echerer <me...@tngtech.com> on 2004/11/08 12:41:21 UTC

Unwanted "focus" JavaScript added for a ValidField


Hi,

in our application we use ValidFields, without utilizing the JavaScript
validation , but nevertheless on of our "required" ValidFields automatically
gets a JavaScript snippet with an on-startup focus. Seems to be always the
first "required" field in the page.
We don't know where and how this is generated and it's quite annoying because
that script doesn't even focus the first input field, but one in the middle of
the page.
How to disable this? Or where to look for this... We definitely have no .script
files.

Cheers,
Michael

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


Re: Unwanted "focus" JavaScript added for a ValidField

Posted by Bryan Lewis <br...@maine.rr.com>.
I was able to work around this in my custom TextField component. (Not that I
like throwing low-level code at a problem... I'll be happy to ditch this
code when it's no longer needed.  I already had a TextField class so it
works for me.)


public abstract class TextField extends ValidField
{
    // ....

    /**
     *  Modify the ValidField readValue() method to remove the auto-focus
     *  feature.  Tapestry's ValidField has a feature to set the focus
     *  (initial cursor location) to the first ValidField that is in error
or
     *  needs a value. That doesn't work well in long forms... the focus
     *  can start in a field that's way down the page, and after a
     *  validation error the user can't see the messages at the top.
     *  For now, turn the feature off.
     */
    protected String readValue()
    {
        // Call autoSelect() the first time we're called.
        // This will put the focus on the first TextField.
        addSelect(getPage().getRequestCycle());

        // Paste the rest of the parent class's readValue() method...
        IValidationDelegate delegate = getForm().getDelegate();

        if (delegate.isInError()) {
            return delegate.getFieldInputValue();
        }

        Object value = getValue();
        String result = getValidator().toString(this, value);

        return result;
    }






----- Original Message ----- 
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Monday, November 08, 2004 8:57 AM
Subject: Re: Unwanted "focus" JavaScript added for a ValidField


> There is no way to disable this currently, sadly.  I, too, would like
> to see this done better and more flexibly.  The JavaScript for that
> focus is in the @Form component.  My hunch, without looking at the
> code, is that you'll have to fix @Form itself or create your own form
> wrapper component.
>
> Erik
>
> On Nov 8, 2004, at 6:41 AM, Michael Echerer wrote:
>
> >
> >
> > Hi,
> >
> > in our application we use ValidFields, without utilizing the JavaScript
> > validation , but nevertheless on of our "required" ValidFields
> > automatically
> > gets a JavaScript snippet with an on-startup focus. Seems to be always
> > the
> > first "required" field in the page.
> > We don't know where and how this is generated and it's quite annoying
> > because
> > that script doesn't even focus the first input field, but one in the
> > middle of
> > the page.
> > How to disable this? Or where to look for this... We definitely have
> > no .script
> > files.
> >
> > Cheers,
> > Michael
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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


Re: Unwanted "focus" JavaScript added for a ValidField

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
There is no way to disable this currently, sadly.  I, too, would like 
to see this done better and more flexibly.  The JavaScript for that 
focus is in the @Form component.  My hunch, without looking at the 
code, is that you'll have to fix @Form itself or create your own form 
wrapper component.

	Erik

On Nov 8, 2004, at 6:41 AM, Michael Echerer wrote:

>
>
> Hi,
>
> in our application we use ValidFields, without utilizing the JavaScript
> validation , but nevertheless on of our "required" ValidFields 
> automatically
> gets a JavaScript snippet with an on-startup focus. Seems to be always 
> the
> first "required" field in the page.
> We don't know where and how this is generated and it's quite annoying 
> because
> that script doesn't even focus the first input field, but one in the 
> middle of
> the page.
> How to disable this? Or where to look for this... We definitely have 
> no .script
> files.
>
> Cheers,
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


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