It’s just a simple Primefaces lightBox I want to use commandLinks in. Unfortunately it simply closes, when I click a commandLink. Is there a way to keep the lightBox open?
Here an example of what my code looks like:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui" template="template.xhtml">
<ui:define name="content">
<p:lightBox>
<h:outputLink value="#">
<h:outputText value="open lightbox" />
</h:outputLink>
<f:facet name="inline">
<h:form>
<h:commandLink>
commandLink
</h:commandLink>
</h:form>
</f:facet>
</p:lightBox>
</ui:define>
</ui:composition>
Use an ajax (asynchronous) request instead of a synchronous request:
or as you’re using PrimeFaces already, just use
<p:commandLink>instead (it uses by default already ajax):With ajax, by default no fresh page replacement with the response is performed (which basically “resets” anything to defaults). You can in case of
<f:ajax>tell byrenderattribute which parts of the component tree should be updated in the client side and in<p:commandLink>by theupdateattribute. E.g. if you want to render/update the parent form only, use@form. E.g.