a4j:commandButton with rich:modalpanel not working
mvg90 Aug 25, 2009 2:51 AMI am trying to edit a list page with a modalpanel similar to the demo in this page
http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=editDataTable
When I click the edit link, I am able to open a modalpanel with the data to edit. But when I edit the data and press update actionlistener is not working.
This is my jsp page
<f:view>
<h:form>
<rich:panel>
<f:facet name="header">
<h:outputText value="Product"></h:outputText>
</f:facet>
<a4j:outputPanel ajaxRendered="true">
<rich:dataTable value="#{productManager.productInfo}" var="product" ajaxKeys="#{productManager.rowsToUpdate}" id="table" captionClass="trialForDataTable" columnClasses="trialForDataTable" headerClass="trialForDataTable" rows="5" onRowMouseOver="this.style.backgroundColor='#B5CEFD'" onRowMouseOut="this.style.backgroundColor='#ffffff'">
<h:column>
<f:facet name="header">
<h:outputText value="Name"></h:outputText>
</f:facet>
<h:outputText id="name1" value="#{product.name}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Description"></h:outputText>
</f:facet>
<h:outputText id="description1" value="#{product.description}"/>
</h:column>
<h:column>
<a4j:commandButton value="Edit"
oncomplete="#{rich:component('useredit')}.show()"
reRender="userinfo">
<f:setPropertyActionListener value="#{product}"
target="#{productManager.product}" />
</a4j:commandButton>
</h:column>
</rich:dataTable>
</a4j:outputPanel>
<richfaces:datascroller for="table" maxPages="10">
<f:facet name="first">
<h:outputText value="First"/>
</f:facet>
<f:facet name="last">
<h:outputText value="Last"/>
</f:facet>
</richfaces:datascroller>
<a4j:keepAlive beanName="productManager"/>
<rich:modalPanel id="useredit" moveable="true">
<f:facet name="header">
<h:outputText value="Product"></h:outputText>
</f:facet>
<h:form>
<h:panelGrid id="userinfo">
<h:outputLabel for="name" value="Name:"/>
<h:inputText id="name" value="#{productManager.product.name}"/>
<h:outputLabel for="description" value="Description:"/>
<h:inputText id="description" value="#{productManager.product.description}"/>
<a4j:commandButton reRender="name1,description1" actionListener="#{productManager.save}" oncomplete="if (#{facesContext.maximumSeverity==null})#{rich:component('useredit')}.hide()" value="Save" ajaxSingle="true" >
</a4j:commandButton>
<a onclick="Richfaces.hideModalPanel('useredit');" href="#">Hide</a>
</h:panelGrid>
</h:form>
</rich:modalPanel>
<a4j:status onstart="#{rich:component('wait')}.show()" onstop="#{rich:component('wait')}.hide()"/>
<rich:modalPanel id="wait" autosized="true" width="200" height="120" moveable="false" resizeable="false">
<f:facet name="header">
<h:outputText value="Processing"/>
</f:facet>
<h:outputText value="Wait Please..."/>
</rich:modalPanel>
<rich:messages></rich:messages>
</rich:panel>
</h:form>
</f:view>and my java code is
public class ProductManager
{
private Set <Integer>rowsToUpdate;
private Product product = new Product();
private List<Product> productInfo = new ArrayList<Product>();
public void init()
{
rowsToUpdate = new HashSet<Integer>();
}
public Product getProduct()
{
System.out.println("Getting product");
setNameToUpdate(product.getName());
return product;
}
public void setProduct(Product product)
{
System.out.println("Setting product");
this.product = product;
}
public void save (ActionEvent event)
{
System.out.println("Save method");
rowsToUpdate.clear();
rowsToUpdate.add(productInfo.indexOf(product));
}
}As in the above I added print statement to make sure the method is called when the save button is clicked. But it is not getting called. Please help me.
Thanks in advance.