webtier@glassfish.java.net

f:ajax and submitting forms, with _at_ConversationScoped beans

From: <webtier_at_javadesktop.org>
Date: Tue, 23 Mar 2010 19:56:01 PDT

I was wondering how to deal with a form using f:ajax to validate fields. The HTML fragment is something like this (incomplete but you get the idea):

<form method="post" id="login" jsfc="h:form">
    <h:inputText type="password" id="password" jsfc="h:inputSecret"
                         value="#{login.password}" redisplay="true">

        <f:ajax render="passwordError" />

    </h:inputText><h:message for="password" id="passwordError" />

    <input type="submit" id="login" value="Login" jsfc="h:commandButton"
               action="#{login.login}" />
</form>

I have two problems - one with this, the other if I try a particular solution:

If I type into this field and then click the submit button straight away, I get the following error as a popup: "httpError: The Http Transport returned a 0 status code. This is usually the result of mixing ajax and full requests. This is usually undesired, for both performance and data integrity reasons."

I gather this is because I have two Ajax requests going on simultaneously (one for the field, the other for the form submission). Often I get an error when this occurs.

One solution was suggested at http://weblogs.java.net/blog/driscoll/archive/2009/10/01/mixing-ajax-and-full-requests-jsf-20 . But if I add a <f:ajax execute="@form" /> to the h:commandButton, I have problems with the backing bean - the password is not set as part of the backing bean, which leads to redisplay problems.

Has anybody seen this problem? I think part of it has been seen in https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=992 but couldn't be reproduced - I can reproduce it all the time.
Is this a suggested way to work around this, so my backing bean gets my password value?

Thanks,

Ian
[Message sent by forum member 'hirowla']

http://forums.java.net/jive/thread.jspa?messageID=393390