I have a problem with RequestContext.update and scrollTo within a Portlet.
Here the implementation (PF 3.5), the behaviour is no update (even if a breakpoint allow me to detect that the method is invoked and i can see the <partial-response><changes><update id="javax.faces.ViewState">IZuHfC8ekpjXbJ9+SCHZLaAa7+/lC/4/KEpSk1+/tZXD4N3dV6SVKEOgDYH2ABw4mz6oWeIITJk7GwViop1kM66zKjlkRv3hfZP1NuqH1wluJqal5rNBxFK4VDA=</update></changes></partial-response> AJAX response) and with scrollTo i get a "b is undefined" javascript error.
Code: Select all
<f:view>
<h:outputStylesheet id="stylesheet1" name="theme.css" library="primefaces-aristo"></h:outputStylesheet>
<h:outputStylesheet id="stylesheet2" name="primefaces.css" library="primefaces"></h:outputStylesheet>
<h:outputScript id="script1" name="jquery/jquery.js" library="primefaces"></h:outputScript>
<h:outputScript id="script4" name="jquery/jquery-plugins.js" library="primefaces"></h:outputScript>
<h:outputScript id="script2" name="primefaces.js" library="primefaces"></h:outputScript>
<h:form>
<h3 style="margin-top:0">RequestContext (update)</h3>
<p:selectBooleanCheckbox id="checkbox" itemLabel="Update first output"
value="#{requestContextController.firstOutput}"/>
<h:panelGrid columns="2" style="margin-top:10px;">
<h:outputText value="First Output"/>
<h:outputText id="firstOutput" value="#{requestContextController.counter}"/>
<h:outputText value="Second Output"/>
<h:outputText id="secondOutput" value="#{requestContextController.counter}"/>
<f:facet name="footer">
<p:commandButton value="Increment counter"
actionListener="#{requestContextController.incrementWithUpdate}"
process="@form" style="margin:10px 0 10px 0;"/>
</f:facet>
</h:panelGrid>
<h3 style="margin-top:20px">RequestContext (scrollTo)</h3>
<h:panelGrid id="counter" columns="2" style="font-weight:bold;">
<h:outputText value="Counter"/>
<h:outputText value="#{requestContextController.counter}"/>
</h:panelGrid>
<p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p>
<p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p>
<p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p>
<p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p>
<p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p>
<p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p>
<p:commandButton value="Increment counter"
process="@form" update="counter"
actionListener="#{requestContextController.incrementWithScroll}"
style="margin:10px;"/>
</h:form>
</f:view>
Code: Select all
@ManagedBean(name = "requestContextController")
@ViewScoped
public class RequestContextController implements Serializable {
private boolean firstOutput = true;
private int counter = 0;
public void incrementWithUpdate(ActionEvent ae) {
counter++;
RequestContext requestContext = RequestContext.getCurrentInstance();
if (firstOutput) {
requestContext.update("firstOutput");
} else {
requestContext.update("secondOutput");
}
}
public void incrementWithScroll(ActionEvent ae) {
counter++;
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.scrollTo("counter");
}
[...]