problem with a4j:commandButtom in rich:popupPanel
dandii Jan 28, 2011 8:08 AMhi again,
in my last discussion about the combination of a rich:dataTable and a rich:popupPanel the following solution was working.
After implementing the functionality of the a4j:commandButton I realized, that this is not the case.
In the listed code the h:button in the rich:popupPanel works stable. Also the method entityHome.remove(Long, String) is called by the a4j:commandButton. Both buttons are returning the same Link ("entity/entityList") but the popupPanel disappears only with the h:button.
When I call the remove method with a different link everything works fine. It looks like that link (in this case it is the link where this code is located) is not reloaded.
How can I call the remove method and can be forwarded to the same page again?
<h:form id="listForm"> <h:panelGroup id="searchResults"> <rich:panel id="richPanel"> <f:facet name="header">List</f:facet> <a4j:outputPanel id="outPanel"> <div class="results" id="entityList"> <rich:dataTable id="dataTable" var="entity" value="#{entityList.resultList}" > <rich:column> <f:facet name="header">#{messages.id}</f:facet> <h:link id="idLink" value="#{entity.id}" outcome="/entity/entity"> <f:param name="entityIdd" value="#{entity.id}" /> </h:link> </rich:column> <!-- other columns --> <rich:column style="width:20px;text-align:center"> <f:facet name="header"> </f:facet> <h:commandLink id="delete" action="#{fileUploadHome.remove(entity.id)}" render="outPanel"> <h:graphicImage name="img/delete.gif" alt="Delete" style="border:0px" /> <rich:componentControl target="popup" operation="show" /> <rich:componentControl target="popup" operation="show" /> <rich:popupPanel id="popup" height="100" width="300" resizeable="false"> <f:facet name="header"> <h:outputText value="Some Text" /> </f:facet> <h:outputText value="Do you really want to delete this entity?" /> <br /> <h:outputText value="ID: #{entity.id}" /> <br /> <div class="actionButtons"> <h:button id="cancel" value="#{messages.cancel}" outcome="/entity/entityList" /> <a4j:commandButton id="deleteButton" value="#{messages.delete}" action="#{entityHome.remove(entity.id, '/entity/entityList')}" /> </div> </rich:popupPanel> </h:commandLink> </rich:column> </rich:dataTable> </div> </a4j:outputPanel> </rich:panel> </h:panelGroup> </h:form>
Here the remove(Long, String) method of entityHome:
public String remove(Long id, String origin){ String remove = remove(id); return (origin == null || origin.equalsIgnoreCase("")) ? remove : origin; }