Hi,
It didn't quite work anyway. It only works if the zone is visible, when I
set visible=false zone2 does not receive focus, but if i submit twice from
zone 1, zone 2 receives focus on the second submit.

- First submit (from zone 1)
  - Zone 2 is set to visible and rendered
  - No focus on zone 2
- Second submit (from zone 1)
  - Zone 2 was already visible
  - focus is set correctly

In both cases the onSetFocus() method is called.

/Thomas

2012/10/4 Thomas Jensen <tapes...@tj-development.dk>

> Hi,
> Great, that fixed the problem. Thank you very much.
>
> /Thomas
>
>
>
> Den 04/10/2012 kl. 10.44 skrev "Poder, Jacob" <
> jacob.po...@thermofisher.com>:
>
> > After the zone update, the id is probably no longer simply
> "transactionText".
> > Try injecting the field and using the clientId, something like this:
> >
> > @Component
> > private TextField transactionText;
> >
> > public void onSetFocus() {
> >    javaScriptSupport.autofocus(FieldFocusPriority.OVERRIDE,
> transactionText.getClientId());
> > }
> >
> >
> > Best regards,
> > Jacob Poder
> >
> >
> > -----Original Message-----
> > From: Thomas Jensen [mailto:tapes...@tj-development.dk]
> > Sent: Wednesday, October 03, 2012 10:14 PM
> > To: Tapestry users
> > Subject: Re: Change textfield focus on zone update
> >
> > 2012/10/3 Poder, Jacob <jacob.po...@thermofisher.com>
> >
> >> There is even a specific method for the purpose, see
> >> JavaScriptSupport.autofocus
> >>
> >> I have used that successfully in a similar case.
> >>
> >> Best regards,
> >> Jacob Poder
> >>
> >>
> >> -----Original Message-----
> >> From: Lance Java [mailto:lance.j...@googlemail.com]
> >> Sent: Wednesday, October 03, 2012 9:50 AM
> >> To: users@tapestry.apache.org
> >> Subject: Re: Change textfield focus on zone update
> >>
> >> On second thought... it might be easier to send some javascript to the
> >> client when form 1 is posted via JavaScriptSupport.addScript(...)
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >> http://tapestry.1045711.n5.nabble.com/Change-textfield-focus-on-zone-u
> >> pdate-tp5716599p5716601.html Sent from the Tapestry - User mailing
> >> list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> > Hi,
> > thanks for the reply's. I've tried to use the JavaScriptSupport but I
> can't seem to get it to do exactly what I want. I've got the following code
> for zone 2 (I've set visible="true" for testing purposes, it is supposed to
> be
> > "false"):
> > *
> > *
> > *<t:zone t:id="popupZone" id="popupZone" visible="true">*
> > *        <div class="overlay">*
> > *            <div style="float:right"><t:actionlink
> > t:id="closePopupZone">X</t:actionlink></div>*
> > *            <strong>${selectedCustomer.firstName}
> > ${selectedCustomer.lastName} Saldo: ${selectedCustomer.saldo} </strong>*
> > *            <p>*
> > *                <t:form t:id="transaction">*
> > *                    <p>Tekst: <t:textfield t:id="transactionText"
> > t:value="transaction.text" size="50"/></p>*
> > *                    <p>Køb: <t:textfield t:value="transaction.value"
> > size="10"/></p>*
> > *                    <t:submit value="Gem"/>*
> > *                </t:form>*
> > *            </p>*
> > *        </div>*
> > *        <t:trigger event="setFocus"/>*
> > *    </t:zone>*
> >
> > The "onSetFocus" event looks like this:
> >
> >   * @Log*
> > *    public void onSetFocus() {*
> > *
> > *
> > *        //if(selectedCustomer.getFirstName() != null) {*
> > *          javaScriptSupport.autofocus(FieldFocusPriority.OVERRIDE,
> > "transactionText");*
> > *        //}*
> > *
> > *
> > *
> > *
> > *    }*
> >
> > When first loading the page, the "onSetFocus" event is called and the
> focus is set to "transactionText" field, as expected. But when submitting
> the form in zone 1, which updates zone 2, I get the following error "cannot
> call method 'activate' on null" (the "onSetFocus" is called, when updating
> zone2).
> >
> > The problem I actually try to solve, is to set focus on the
> "transactionText" field, when zone 2 is updated, so it should not have
> focus on initial page load.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
>

Reply via email to