• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need a fix for <a4j:commandLink> to both run an action and oncomplete event.

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone and thank you for your time.

Our website runs on Java SEAM/JSF 1.2/RichFaces3.x.x and Facelets is there on the front-end as well.

I mostly work on another platform and language but am transitioning to this platform, so pardon me if I lack clarity in any areas.

I want to create a one text input form with a submit button, using ajax4jsf or a4j, and then once the bean.method is fired and a record stored in the DB - I need to rename the wrapper div's id attribute and insert some new innerHTML.

I was wondering if you all had suggestions on how to do this with your own approach?

and/or also I can show my try at tackling this simple problem next:
--------------------------------------------------------------------------------------------------

I have some code that I have managed to get working in Chrome, IE8, but not FireFox. BTW: my a4j: namespace is a: so that is what a: is in the code.

In FireFox, the correctly submits a record to the database and does not return any values.

Next the oncomplete attribute fires an event to a JavaScript function - it's job is to replace the wrapper div id and load the new content.

First a portion of what I have in the front page code:



And then the Javascript functions:



Hopefully there is enough information for us to at least look at the reason it failed in FireFox, but let me know if more information is needed. The Method in the bean is confirmed to work. And not a good idea to share it anyway.

Thanks all very much!

A VERY IMPORTANT P.S >>

Ok so my testing involves making sure you can BOTH click the button to submit your email AND type your email and just hit the Enter key. The only thing of all the browsers tested that failed is FireFox 14 (ithink) and it failed when typing and pressing Enter Key. It actually works in all browsers if you click the Submit button.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are major differences between IE and Firefox when it comes to handling the ENTER key on a form.

Beyond that, a couple of minor observations:

1. I don't think "return false();" has meaning in oncomplete. onsubmit would be different.

2. RichFaces comes with some JSF-friendly macros that make it easier to access JSF DOM objects.

3. RichFaces also comes with a built-in (if antique) copy of jQuery that can make it easier to rearrange DOM objects in a browser-portable manner (and less code than raw javascript).

4. I'd be cautious about actually changing the IDs on DOM object, regardless.

5. Usually when I make the View mutable - which I rarely do on account of it's not generally recommended - I prefer to bind the root object of of mutating part of the View to a backing bean, let the backing bean meddle with the UI elements, and, when using AJAX, let the RichFaces reRender kick off the UI update. That way I don't need any oncomplete= javascript.
reply
    Bookmark Topic Watch Topic
  • New Topic