• 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

Why does not command button calls action listener?

 
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again!

I have embedded prettyfaces recently into my webapp and now I have really strange behaviour.
I have register form and command link within it:
<h:commandLink id="registerButton" class="registerButton" value="Register" type="submit" action="#{registerBacking.create}" />

Neither command link nor command button invokes action method which is registerBacking.create.
My registerBacking View-Scoped bean is created only when using page is loaded.
When I click this link I simply reload the page and registerBacking is created again, no validation and conversion error arises although there are many errors.
And this link and button is placed within h:form.
To prevent view-scoped bean to be recreated al time I set this in web.xml:



 
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
Try setting the onPostBack option to false. You shouldn't have to hack web.xml.
 
Bin Smith
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Tim!

Unfortunately onPostback="false" does not make any difference. However if I remove mapping from pretty-config.xml all is working well as before
My mapping is simple

PrettyFaces documentation says that we should use onPostback="false" but not onPosBack="false". I tried both and they didn't work!
What is wrong here?
 
Tim Holloway
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
You are specifying a resource path (.xhtml) for the view-id. The view-id should be a URI, just like in the faces-config,xml. Try "/register.jsf", instead.
 
Bin Smith
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Tim!

Bad news!

I have replaced FacesServlet maping to .jsf in web.xml and changed pretty faces mapping to:

Unfortunately it didn't make any difference! My action method is not called anyway!

Do you have another ideas?
By the way before embedding prettyfaces this was working well.

If I intentionally type wrong data I receive this notification from browser:

httpError: Http Transport returns a 0 transport code. This is usually the result of mixing ajax and full requests. This is usually undesired both for performance and data integrity reasons!


Thank you!
 
Tim Holloway
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
I am very confused.

There are only 3 ways I can think of that prevent the action method from being invoked, and they are independent of prettyfaces.

1. If you have an improper rendering of the View containing the commandLink/Button. This can be diagnosed by using your browser's "View Page Source" feature. If the original "h:commandLink" is in the displayed source, the page wasn't rendered properly.

2. If the commandLink isn't part of a JSF form, it won't work. You must have it contained within a form.

3. If the commandLink is part of a form containing invalid control values, the JSF validation services will reject the action and bypass the action method.

To avoid case 3, add an "immediate="true"" attribute to your commandLink. That will keep the invalid control values from being submitted.
 
Bin Smith
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for replies !!!

I have made sure that the problem is just in this mapping in pretty-config:


I commented out this mapping and my button is working as needed. My form is submitted and new user is created and it is stored in db.
But if I paste this mapping back into pretty-config.xml I have no response to clicking the same button from the same form.
You advised me to move to .jsf mapping for FacesServlet. Very interesting is that this caused my action method NOT to be invoked even if I removed that
cursed mapping from pretty-config.xml.
I am sure the problem is above mapping.

By the way I thought that this causes problems:

I deliberetely removed it and it didn't make any difference for button. It invokes action method when there is no that mapping in pretty-config.xml.
I keep javax.faces.FULL_STATE_SAVING_VIEW_IDS in order to prevent view scoped bean to be recreated all the time while I am filling the form.
And it works!

I posted this issue on ocpsoft/support and I still don't have reply!
 
Bin Smith
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for replies!

httpError: Http Transport returns a 0 transport code. This is usually the result of mixing ajax and full requests. This is usually undesired both for performance and data integrity reasons!


This was happenning just because my ajax request was sent together with full request as I clicked submit button.
The same problem is very well described here http://weblogs.java.net/blog/driscoll/archive/2009/10/01/mixing-ajax-and-full-requests-jsf-20

As soon as I changed command button to
<h:commandButton id="registerButton" class="registerButton" value="Register" type="submit" action="#{registerBacking.create}">
<f:ajax render="@form" />
</h:commandButton>
All problems have gone away!
And now regardless of pretty-config mapping I am redirected to needed page and new user is persisted into database!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic