reRender problem
henrik.lindberg Mar 24, 2007 9:40 AMHi,
In my facelet (below) I am using ajax calls when selecting a row in a data table. When the row is selected I want to update a panel with a value from the selected value.
At first nothing happened. I then added a <h:outputText> right after the datascroller and I had it output "selectedSpace.spacename" - then it magically worked - I found out however that it was not because of accessing selectedSpace - jut the precense of an h:outputText makes the panel re-render.
What am I doing wrong here to get this strange effect?
(The code below behaves as I want, but why do I need the extra h:outputText???)
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
template="layout/template.xhtml">
<ui:define name="title">Spaces</ui:define>
<ui:define name="body">
<div id="wrap-cspaces">
<img id="spacesHeading" src="/img/heading.png" />
<a href="FAQ-spaces.seam"><img class="infoButton" id="spacesInfo"
src="/img/info.button.png" /></a>
</div>
<div class="Divider2" id="cspaces-topDivider"/>
<f:view>
<!-- ADDING NEW SPACE -->
<div id="addSpaceBox"><h:form id="addSpaceForm">
<s:validateAll>
<h:outputLabel for="spaceInput">Wanted Public Space Name:</h:outputLabel>
<h:inputText
styleClass="InputField"
id="spaceInput"
value="#{userSpaces.spaceInput}"
required="true"
maxlength="93" />
<h:commandButton type="submit" value="Add Space"
action="#{userSpaces.addSpace}"
image="/img/create.new.space.grey.btn.png" />
<h:message for="spaceInput" />
<h:messages globalOnly="true" />
</s:validateAll>
</h:form></div>
<div class="Divider2" id="cspaces-bottomDivider"/>
<h:outputText
rendered="#{availableSpaces == null or not (availableSpaces.rowCount > 0)}"
styleClass="warn"
value="There are no spaces to display. Add wanted space(s) using the box above." />
<h:form id="spaceForm">
<h:dataTable
id="space_list"
styleClass="fence"
value="#{availableSpaces}"
var="p"
rendered="#{availableSpaces != null and availableSpaces.rowCount > 0}"
rowClasses="first,second"
columnClasses="col1class,col2class"
first="#{userSpaces.first}"
rows="#{userSpaces.pageSize}">
<h:column>
<f:facet name="header">name</f:facet>
<a4j:commandLink value="#{p.spaceName}" action="#{userSpaces.select(p)}" reRender="contentList" />
</h:column>
<h:column>
<f:facet name="header">created</f:facet>
<h:outputText value="#{p.dateAdded}" />
</h:column>
</h:dataTable>
<rich:datascroller
for="space_list"
rendered="#{availableSpaces != null and availableSpaces.rowCount > 0}"
maxPages="9"
id="paginator"
renderIfSinglePage="false"
/>
<h:outputText value="" /> <!-- WHY IS THIS NEEDED -->
<a4j:outputPanel id="contentList" ajaxRendered="true">
<div id="pos-spacesContent">
<div id="wrap-spacesContent" class="shadow">
<div class="shadow2">
<div id="spacesContentBox" class="shadowed">
<div id="spacesContentHeader">
<h:outputText
value="#{selectedSpace.spaceName}"
styleClass="spacesContentHeader"
rendered="#{selectedSpace != null}" />
<h:outputText
value="No space selected"
styleClass="warn spacesContentHeader"
rendered="#{selectedSpace == null}" />
</div>
<div class="Divider2" id="spaces-content-divider" />
</div>
</div>
</div>
</div>
</a4j:outputPanel>
</h:form>
</f:view>
</ui:define>
</ui:composition>
Any comment or suggestion is welcome.