Re: Change textfield focus on zone update

2012-10-09 Thread nquirynen
Well I'm afraid you just can't set focus on a hidden element. So you have to
try to set the focus after it is visible. Maybe use of
Tapestry.ZONE_UPDATED_EVENT as lance firstly suggested might work.


$('formZone').observe(Tapestry.ZONE_UPDATED_EVENT, function(event) {
// set the focus
}); 



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Change-textfield-focus-on-zone-update-tp5716599p5716721.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



Re: Change textfield focus on zone update

2012-10-04 Thread Thomas Jensen
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 

> 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 
> >
> >> 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:id="closePopupZone">X*
> > *${selectedCustomer.firstName}
> > ${selectedCustomer.lastName} Saldo: ${selectedCustomer.saldo} *
> > **
> > **
> > *Tekst:  > t:value="transaction.text" size="50"/>*
> > *Køb:  > size="10"/>*
> > **
> > **
> > **
> > **
> > **
> > **
> >
> > 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
> >
>


Re: Change textfield focus on zone update

2012-10-04 Thread Thomas Jensen
Hi,
Great, that fixed the problem. Thank you very much. 

/Thomas



Den 04/10/2012 kl. 10.44 skrev "Poder, Jacob" :

> 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 
> 
>> 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:id="closePopupZone">X*
> *${selectedCustomer.firstName}
> ${selectedCustomer.lastName} Saldo: ${selectedCustomer.saldo} *
> **
> **
> *Tekst:  t:value="transaction.text" size="50"/>*
> *Køb:  size="10"/>*
> **
> **
> **
> **
> **
> **
> 
> 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
> 

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



RE: Change textfield focus on zone update

2012-10-04 Thread Poder, Jacob
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 

> 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"):
*
*
**
**
*X*
*${selectedCustomer.firstName}
${selectedCustomer.lastName} Saldo: ${selectedCustomer.saldo} *
**
**
*Tekst: *
*Køb: *
**
**
**
**
**
**

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



Re: Change textfield focus on zone update

2012-10-03 Thread Thomas Jensen
2012/10/3 Poder, Jacob 

> 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-update-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"):
*
*
**
**
*X*
*${selectedCustomer.firstName}
${selectedCustomer.lastName} Saldo: ${selectedCustomer.saldo} *
**
**
*Tekst: *
*Køb: *
**
**
**
**
**
**

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.


RE: Change textfield focus on zone update

2012-10-03 Thread Poder, Jacob
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-update-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



Re: Change textfield focus on zone update

2012-10-03 Thread Lance Java
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-update-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



Re: Change textfield focus on zone update

2012-10-03 Thread Lance Java
Tapestry fires a clientside event when a zone is updated with new content.
You can attach a listener to the event Tapestry.ZONE_UPDATED_EVENT
("tapestry:zoneupdated"). Listening to clientside events depends on the
clientside framework you are using. Use observe(...) for prototype or
on(...) for tapestry-jquery.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Change-textfield-focus-on-zone-update-tp5716599p5716600.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