Question

I have on my page:

<h:form id="qw">
    <h:panelGrid columns="3" >
           <h:outputLabel for="username" value="Login:"/>
           <h:inputText id="username" value="#{userManager.userName}" required="true">
              <f:ajax event="blur" render="usernameMessage"/>
           </h:inputText>
           <h:message id="usernameMessage" for="username" />

           <h:outputLabel for="password" value="#{msg.password}"/>
           <h:inputSecret id="password" value="#{userManager.password}" required="true">
              <f:ajax event="blur" render="passwordMessage" />
            </h:inputSecret>
            <h:message id="passwordMessage" for="password" />

           <h:commandButton value="#{msg.login}" action="#{userManager.login}">
              <f:ajax execute="@form" render=" @form qw usernameMessage passwordMessage messages"/>
           </h:commandButton> 
       </h:panelGrid>
   </h:form>

   <h:messages id="messages" globalOnly="true"/>

When I run application and click "Log in" button I get this error:

Error Message: Request failed with status 0 and reason 

--------------------------------------------------------
Calling function:myfaces._impl.xhrCore._AjaxRequest
Error Name: httpError

What does it mean? What is wrong? I can't use h:commandButton with Ajax?

Was it helpful?

Solution

the xhtml looks fine when using JSF2. You open a form, use input fields, message and an ajaxified commandButton. You can skip rerendering qw, usernameMessage and passwordMessage - they are already part of @form.

h:messages is outside the form, which shouldn't be from any harm. Possibly it's a special problem with the myFaces-implementation or you just lost a connection somehow - JSF-wise you should be safe.

OTHER TIPS

After reading L-Ray answer I realized that h:messages is outside the form, so it i have to add : before name messages. It should be:

    <h:commandButton value="#{msg.login}" action="#{userManager.login}">
        <f:ajax execute="@form" render=" @form :messages"/>
    </h:commandButton> 

For more info about it read: http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentOutsideForm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top