0 Replies Latest reply on Jul 13, 2008 11:01 PM by Bernard Chan

    Mixing AJAX postback and conventional postback

    Bernard Chan Newbie

      Being pretty new to JSF and Ajax4jsf/Richfaces myself I have a query for now out of an Ajax-enabled webapp I am asked to build.

      Basically, I am trying to build a view with a Javascript tab control with two tabs. The tab control is actually a JQuery tab control and is irrelevant in the JSF lifecycle. Both tabs contain a login form.

      Here is what I have now for one of the login forms:

      <a4j:form id="tourop_frm_login" ajaxSubmit="true">
      <a4j:outputPanel ajaxRendered="true" layout="block">
      <div class="error"><h:messages id="tourop_errmsg" /></div>
      <table class="frm">
      <tr><td class="colLabel">Company ID</td><td><h:inputText value="#{tourop_credentials.id}" id="tourop_tc" required="true" /></td></tr>
      <tr><td class="colLabel">Password</td><td><h:inputSecret value="#{tourop_credentials.password}" id="tourop_pass" required="true" /></td></tr>
      <div class="buttonBar"><a4j:commandButton action="#{tourop_authen.authenticate}" value="Login" timeout="10000" /></div>

      As the tab control is not JSF-enabled, if there is a postback due to login failure, I believe the active tab cannot be kept as expected. So I would like to do an AJAX-based login with the following characteristics:

      - If login failed, display an error message as an AJAX postback by manipulating FacesContext and updating using ajax4jsf.
      - If login successful, redirect whole page to the new view. I expect the view resolution mechanism will be based on the same configuration means as Seam using Seam pageflow (or not, depending on needs).

      For the login failed scenario, I have successfully implemented it. I can see the error message updaing <h:messages /> dynamically. However, I have no idea how or if I can implement the success scenario. If without using AJAX, I simply return from the action an outcome string that will be resolved by the navigation to resolve the next view, and plain old JSF will always refresh the entire page. That's my understanding of how JSF and Seam Pageflow work.

      I'm using the bundled Ajax4jsf/Richfaces in JBoss Seam 2.0.3 deployed on JBoss AS 4.2.x. The above is written as embedded tags in JSP rather than Facelets as recommended by Seam framework.

      Appreciate any suggestions. Pardon if this is very simple question but I could not find anything online useful in this regard and I am quite confused by the behaviour of Ajax4jsf looking for some clarifications. Thank you.