Prime Faces评级未显示

时间:2017-04-23 14:07:55

标签: ajax jsf primefaces xhtml

在maven项目中 我使用的是Prime Faces评级样本 https://www.primefaces.org/showcase/ui/input/rating.xhtml

但它无法显示样本的相同视图

servlet代码:

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

import org.primefaces.event.RateEvent;
@ManagedBean
public class RatingView {

    private Integer rating3;    


    public void onrate(RateEvent rateEvent) {
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Rate Event", "You rated:" + ((Integer) rateEvent.getRating()).intValue());
        FacesContext.getCurrentInstance().addMessage(null, message);
    }

    public void oncancel() {
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cancel Event", "Rate Reset");
        FacesContext.getCurrentInstance().addMessage(null, message);
    }



    public Integer getRating3() {
        return rating3;
    }

    public void setRating3(Integer rating3) {
        this.rating3 = rating3;
    }

}

XHTML页面:

<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">
    <h:form>
        <p:growl id="messages" showDetail="true" />

        <h:panelGrid columns="2" cellpadding="5">


            <h:outputText value="Ajax Rate:" />
            <p:rating value="#{ratingView.rating3}">
                <p:ajax event="rate" listener="#{ratingView.onrate}" update="messages" />
                <p:ajax event="cancel" listener="#{ratingView.oncancel}" update="messages" />
            </p:rating>


        </h:panelGrid>

        <p:commandButton value="Submit" update="display" oncomplete="PF('dlg').show()" style="margin:5px" />

        <p:dialog header="Values" widgetVar="dlg" showEffect="fade" hideEffect="fade">
            <h:panelGrid id="display" columns="2" cellpadding="5">


                <h:outputText value="Rating 3:" />
                <h:outputText value="#{ratingView.rating3}" />
            </h:panelGrid>
        </p:dialog>
    </h:form>
</ui:composition>

None from the rating is displayed

我的maven Dependecies:我添加了6.0版本的主要面孔 enter image description here

有什么想法吗?

0 个答案:

没有答案