Reputation: 3890
Turns out that faces-config.xml was overriding the inline annotation ViewScoped in my Controller class w/ RequestScoped. Fixed it and that seem to solve the problem.
This question does not have an answer here commandButton/commandLink/ajax action/listener method not invoked or input value not updated and if you think it does, please provide a working fix/example using primefaces fluidGrid extension.
I am using primefaces ui exension fluidGrid : http://fractalsoft.net/primeext-showcase-mojarra/sections/fluidgrid/dynamic.jsf
I can't seem to invoke profileController.testControl() , if I place the commandButton outside of the fluidGrid it works fine , but not within the grid. Any ideas?
I've tested by changing my bean to @ViewScoped , there are no nested forms etc.
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
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="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="resultList" />
</composite:interface>
<composite:implementation>
<h:form id="form1" rendered="true">
<!-- Grid -->
<pe:fluidGrid value="#{resultList}" var="showvar" hGutter="20" rowKeyVar="rowKey" fitWidth="true" hasImages="true" rendered="true" >
<pe:fluidGridItem rendered="true" >
<p:panel id="seriesPanel" rendered="#{showvar.isSeries()}"></p:panel>
<p:panel id="episodePanel" rendered="#{!showvar.isSeries()}" >
<p:commandButton value="click me" action="#{profileController.testControl()}"/>
<!-- another button attempt that doesn't work -->
<p:commandButton process="fluidGrid" value="click me again" ajax="false" actionListener="#{profileController.testControlEvent()}" />
</p:panel>
</pe:fluidGridItem>
</pe:fluidGrid>
</h:form>
</composite:implementation>
</html>
//Tried with @ViewScoped as well
@Model
public class ProfileController {
public void testControl(){
log.info("---------------------------------------");
log.info("TEST CONTROL CLICKED");
log.info("---------------------------------------");
}
public void testControlEvent(ActionEvent actionEvent){
log.info("---------------------------------------");
log.info("TEST CONTROL CLICKED");
log.info("---------------------------------------");
}
}
Upvotes: 2
Views: 2539
Reputation: 17463
I've tried the simple example of having command button inside fluidGrid and it works here.
XHTML File
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form id="login">
<pe:fluidGrid value="#{tBean.images}" var="showvar" hGutter="20"
rowKeyVar="rowKey" fitWidth="true" hasImages="true" rendered="true">
<pe:fluidGridItem rendered="true">
<p:commandButton value="click me" action="#{tBean.doAction}" />
</pe:fluidGridItem>
</pe:fluidGrid>
</h:form>
</h:body>
</html>
ManagedBean code
package bean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.primefaces.extensions.model.fluidgrid.FluidGridItem;
@ManagedBean(name = "tBean")
@ViewScoped
public class TestBean implements Serializable{
private List<FluidGridItem> images;
@PostConstruct
protected void initialize() {
images = new ArrayList<FluidGridItem>();
for (int j = 0; j < 3; j++) {
for (int i = 1; i <= 10; i++) {
images.add(new FluidGridItem("i" + 1));
}
}
}
public void doAction() {
System.out.println("Im doing action");
}
public List<FluidGridItem> getImages() {
return images;
}
}
Try above and see if that works for you. If it works then try to use in your implementation.
Upvotes: 2
Reputation: 53
u must update your form i think in your page add in the button update=":form1:fluidGrid" if dosent work make the ajax on true it helped to solve a problem like this i hope it will help you
Upvotes: 0
Reputation: 314
I have sometimes problem with rendered and button not being invoked. Make sure that your rendered="#{!showvar.isSeries()}"
works correct or remove it and try again.
Upvotes: 0