JSF RichFaces Facelets integration problem
traneti Mar 9, 2011 3:57 AMI have a form inside <ui:define> which after authenticating as admin:admin is just setting a boolean that another RichFaces control checks in its rendered attribute. The problem is that after it does, all that appears in the page is:
[code=java]
<script>A4J.AJAX._scriptEvaluated=true;</script>[/code]
instead of the RichFaces control.
If I refresh the page, the control happily appears. If i refresh again the control remains and [code=java]
<script>A4J.AJAX._scriptEvaluated=true;</script>[/code] dissapears
This seems that Facelets doesn't integrate well with Ajax requests because when is switch to h:form and h:commandButton it works as espected. What should i do to make it work with Ajax?
The page is:
[code=java]<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/pages/templates/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<ui:define name=%252526quot%25253Bheader%252526quot%25253B%252526gt%25253B
<div id="topspacer">header</div>
</ui:define>
<ui:define name=%252526quot%25253Bcontent%252526quot%25253B%252526gt%25253B
<div id="content">
<a4j:form ajaxSubmit="true" id="login">
<table>
<tr>
<td align="right"><h:outputText value="#{msg.username}" /></td>
<td><h:inputText id="username" value="#{loginBean.username}"
required="true">
<f:validateLength maximum="20" minimum="3" />
</h:inputText>
</td>
<td><h:message for="username" style="color:red;" />
</td>
</tr>
<tr>
<td align="right"><h:outputText value="#{msg.password}" /></td>
<td><h:inputSecret id="password"
value="#{loginBean.password}" required="true" />
</td>
<td><h:message for="password" style="color:red;" />
</td>
</tr>
<tr>
<td colspan="3"><a4j:commandButton value="#{msg.login}"
action="#{loginBean.login}" reRender="admin_panel" />
</td>
</tr>
</table>
</a4j:form>
<rich:panel id="admin_panel" rendered="#{loginBean.isInAdmin}">
<a4j:form id="admin_form" ajaxSubmit="true">
<rich:messages style="color:red;" />
<table>
<tr>
<td align="right"><h:outputText value="#{msg.username}" />
</td>
<td><h:inputText id="add_username"
value="#{loginBean.addUsername}">
<f:validateLength maximum="20" minimum="3" />
</h:inputText>
</td>
<td><h:message id="add_username_message" for="add_username"
style="color:red;" />
</td>
</tr>
<tr>
<td align="right"><h:outputText value="#{msg.password}" />
</td>
<td><h:inputSecret id="add_password"
value="#{loginBean.addPassword}" />
</td>
<td><rich:message for="add_password" style="color:red;" />
</td>
</tr>
<tr>
<td align="right"><h:outputText value="#{msg.aisle}" />
</td>
<td><h:inputText id="add_aisle" value="#{loginBean.aisle}" />
</td>
<td><rich:message for="add_aisle" style="color:red;" />
</td>
</tr>
<tr>
<td colspan="3"><a4j:commandButton value="#{msg.add}"
action="#{loginBean.add}" reRender="admin_panel" /></td>
</tr>
<tr>
<td colspan="3"><a4j:commandButton value="#{msg.login}"
action="#{loginBean.success}" />
</td>
</tr>
<tr>
<td colspan="3"><a4j:commandButton value="#{msg.cancel}"
action="#{loginBean.cancel}" />
</td>
</tr>
</table>
</a4j:form>
</rich:panel>
</div>
</ui:define>
<ui:define name=%252526quot%25253Bfooter%252526quot%25253B%252526gt%25253B
Add your footer here or delete to use the default
</ui:define>
</ui:composition>[/code]
EDIT:
lifecycle insight:
[quote]10:12:29,318 INFO [STDOUT] START PHASE RESTORE_VIEW 1
10:12:29,334 INFO [STDOUT] END PHASE RESTORE_VIEW 1
10:12:29,334 INFO [STDOUT] START PHASE APPLY_REQUEST_VALUES 2
10:12:29,334 INFO [STDOUT] is in admins
10:12:29,334 INFO [STDOUT] END PHASE APPLY_REQUEST_VALUES 2
10:12:29,334 INFO [STDOUT] START PHASE PROCESS_VALIDATIONS 3
10:12:29,334 INFO [STDOUT] is in admins
10:12:29,334 INFO [STDOUT] END PHASE PROCESS_VALIDATIONS 3
10:12:29,334 INFO [STDOUT] START PHASE UPDATE_MODEL_VALUES 4
10:12:29,334 INFO [STDOUT] is in admins
10:12:29,334 INFO [STDOUT] END PHASE UPDATE_MODEL_VALUES 4
10:12:29,334 INFO [STDOUT] START PHASE INVOKE_APPLICATION 5
10:12:29,334 WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
10:12:29,334 WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
10:12:29,381 INFO [STDOUT] Hibernate: select users0_.id as id16_, users0_.aisle as aisle16_, users0_.password as password16_, users0_.username as username16_ from USERS users0_ where users0_.username=%253F and users0_.password=?
10:12:29,474 INFO [STDOUT] is in login
10:12:29,474 INFO [STDOUT] END PHASE INVOKE_APPLICATION 5
10:12:29,474 INFO [STDOUT] START PHASE RENDER_RESPONSE 6
10:12:29,474 INFO [STDOUT] is in admins
10:12:29,474 INFO [STDOUT] is in admins
10:12:29,474 INFO [STDOUT] is in admins
10:12:29,474 INFO [STDOUT] is in admins
10:12:29,474 INFO [STDOUT] is in admins
10:12:29,490 INFO [STDOUT] is in admins
10:12:29,490 INFO [STDOUT] is in admins
10:12:29,490 INFO [STDOUT] END PHASE RENDER_RESPONSE 6[/quote]