Forums de discussion
Primefaces ajax is not working
Konstantin Chudinov, modifié il y a 10 années.
Primefaces ajax is not working
Junior Member Publications: 43 Date d'inscription: 23/04/13 Publications récentes
Hi all!
Could someone explain me, what im doing wrong with primefaces' ajax:
view.xhtml:
Could someone explain me, what im doing wrong with primefaces' ajax:
view.xhtml:
<h:form id="myform">
<h:panelgrid columns="1">
...
<p:selectonemenu id="monthSelector" value="#{myBean.selectedMonth}">
<f:selectitems value="#{myBean.monthItems}" />
<p:ajax update="out" listener="#{myBean.monthSelected}" />
</p:selectonemenu>
<h:outputtext id="out" value="#{myBean.i} " ...< code></h:outputtext></h:panelgrid></h:form>
<br>Bean:<br><pre><code>@ManagedBean(name = "myBean")
@SessionScoped
public class MyBean implements Serializable {
private static final long serialVersionUID = -4610109006903875475L;
private int i = 0;
private List<selectitem> monthItems;
private SelectItem selectedMonth;
public MyBean () {
...//filling monthItems
}
public List<selectitem> getMonthItems() {
return monthItems;
}
public void setMonthItems(List<selectitem> monthItems) {
this.monthItems = monthItems;
}
public SelectItem getSelectedMonth() {
return selectedMonth;
}
public void setSelectedMonth(SelectItem selectedMonth) {
this.selectedMonth = selectedMonth;
System.out.println("Value selected");
}
public void monthSelected() {
i++;
System.out.println("Value changed");
}
public int getI() {
return i;
}
}
</selectitem></selectitem></selectitem></code></pre><br><br>So console displays nothing...<br>My xmls are:<br>faces-config:<br><br><pre><code><!--?xml version="1.0"?-->
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<lifecycle>
<phase-listener>com.liferay.faces.util.lifecycle.DebugPhaseListener</phase-listener>
</lifecycle>
</faces-config></code></pre><br><br>liferay-portlet<br><pre><code><liferay-portlet-app>
<portlet>
<portlet-name>MyPortlet</portlet-name>
<icon>/icon.png</icon>
<instanceable>false</instanceable>
<ajaxable>false</ajaxable>
<header-portlet-css>/css/main.css</header-portlet-css>
<css-class-wrapper>MyPortlet-portlet</css-class-wrapper>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>Guest</role-link>
</role-mapper>
<role-mapper>
<role-name>power-user</role-name>
<role-link>Power User</role-link>
</role-mapper>
<role-mapper>
<role-name>user</role-name>
<role-link>User</role-link>
</role-mapper>
</liferay-portlet-app>
</code></pre>
Neil Griffin, modifié il y a 10 années.