QeelwaEtech / omnifaces

Automatically exported from code.google.com/p/omnifaces
0 stars 1 forks source link

onloadScript enhancement #144

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We are using onload script to cause a focus event on the page after an ajax 
call.  This works great for most ajax calls but presents a problem when we have 
a valueChangeListener.  Is there any way to perform an onloadScript that 
doesn't target ajax calls from valueChangeListener?  Maybe an enhancement to 
tie it to specific ajax events only?

Original issue reported on code.google.com by hazen...@gmail.com on 20 Feb 2013 at 4:25

GoogleCodeExporter commented 9 years ago
I'm not sure if I understand the concrete problem. The valueChangeListener 
doesn't send any ajax request. It's just a registration of a server side 
listener method for the case a value is changed during a postback.

Are you using <f:ajax event="valueChange"> on input components? How exactly 
does that cause a problem for focus?

Original comment by balusc on 20 Feb 2013 at 8:18

GoogleCodeExporter commented 9 years ago
A little background on what we are doing in simplistic terms.  After the ajax 
calls, our javascript will cause it to shift focus back to the first input box 
and select all the data.  On key fields, we use valueChangeListener to set a 
boolean in the backing bean to prevent users from attempting updates or deletes 
without reading first.  Anytime the value is changed and the user tabs out of 
that input box, it is hitting the backing bean listener.  It is doing this 
immediately on hitting tab or anything click action away from that input box.  

I'll take another look at this tomorrow when I'm in the office to verify we 
don't have f:ajax in it.  I didn't think that was there so I assumed it was 
using ajax on its own.  I may have just overlooked it.  

Essentially what this causes is that fields we have this on are getting the 
javascript ran when we really don't want it ran.  Generally we only want to run 
the script when we do our main actions such as read, update, delete, etc.  Not 
a huge issue.  It is easy to work around, just not that pretty for the users.  
They basically experience focus being taken away from them after making changes 
in these fields then attempting to tab as it immediately brings back focus to 
the field just changed.

If we are using ajax on this, is there any way to prevent onloadScript for edge 
cases such as this?  At the moment, any ajax we use is @Form for simplicity 
reasons so implementing the script previously only worked for us when using 
liveQuery.  Due to efficiency issues with liveQuery, we replaced that with our 
first use of omnifaces.  I know we could go further with cleaning things up to 
be more efficient but progress is progress sometimes.  I have seen a couple of 
your posts which indicate we might be using valueChangeListener incorrectly in 
our case.  I'm going to look at this as well.

For reference, we are using cdi/weld 1.1.10, mojarra 2.1.19, and richfaces 
4.3.0 along with omnifaces.  So far, things are playing well together.

Original comment by hazen...@gmail.com on 21 Feb 2013 at 12:27

GoogleCodeExporter commented 9 years ago
I verified we were doing ajax.  You can close this issue.  Thanks.

Original comment by hazen...@gmail.com on 21 Feb 2013 at 4:43

GoogleCodeExporter commented 9 years ago
Okay. Thank you for using OmniFaces and reporting anyway :)

Original comment by balusc on 22 Feb 2013 at 1:13