Primefaces计划组件未显示

时间:2013-01-21 06:06:19

标签: jsf primefaces myfaces

我是一个JSF 2.0新手,我正在尝试构建一个调度程序。 到目前为止,在使用primefaces和JSF标签方面,一切都进展顺利。但是我很难使用p:schedule标签。 在列表中,我只想让日历(议程)显示在我的页面中,然后再转到下一部分并添加事件。 我的问题是,这段代码至少不应该在我的页面中产生一些东西吗?

这是我的scheduleBean.java

 @ManagedBean(name="scheduler")
    @ViewScoped
    public class SchedulerBean extends PageCodeBase implements Serializable {

    private static final long serialVersionUID = -1426310201082465397L;
    private String loggedInUser;
    private boolean authorizeduser=false;
    private boolean showUnauthorizeduserMessage=true;
    private String theme;
    private AuthorizeduserManager AUM =  (AuthorizeduserManager)getManagedBean("AuthorizeduserManager");
    private ScheduleModel eventModel;

    public void pageOnLoad(){
        this.setLoggedInUser(getFacesContext().getExternalContext().getRemoteUser());
        this.checkAuthorization();
        this.retriveTheme();
        this.eventModel = new DefaultScheduleModel();
    }

    private void checkAuthorization(){
        ArrayList<Authorizeduser> athorizedUser= new ArrayList<Authorizeduser>();
        athorizedUser.addAll(AUM.getAuthorizeduser());
        for(Authorizeduser au:athorizedUser){
            if (loggedInUser.equalsIgnoreCase(au.getEmail())){
                setAuthorizeduser(true);
                showUnauthorizeduserMessage = false;
                return;
            }
        }   
    }//end checkAuthorization


    private void retriveTheme(){
        if(authorizeduser){
            this.theme = AUM.findAuthorizeduserByEmail(loggedInUser).getThemepref();
        }else{
            this.theme = "blitzer";
        }
    }


    private void persistTheme(String theme){
        //System.out.println("persistTheme was called");
        ArrayList<Authorizeduser> athorUser= new ArrayList<Authorizeduser>();
        athorUser.addAll(AUM.getAuthorizeduser());
        for(Authorizeduser au:athorUser){
            if (loggedInUser.equalsIgnoreCase(au.getEmail())){
                try {
                    au.setThemepref(theme);
                    AUM.updateAuthorizeduser(au);
                } catch (Exception e) {
                    e.printStackTrace();
                }           
            }
        }
    }


    //Getters and setters
    public String getLoggedInUser() {
        return loggedInUser;
    }

    private void setLoggedInUser(String loggedInUser) {
        this.loggedInUser = loggedInUser;
    }

    public boolean isAuthorizeduser() {
        return authorizeduser;
    }

    private void setAuthorizeduser(boolean authorizeduser) {
        this.authorizeduser = authorizeduser;
    }

    public boolean isshowUnauthorizeduserMessage() {
        return showUnauthorizeduserMessage;
    }

    public void setshowUnauthorizeduserMessage(boolean showUnauthorizeduserMessage) {
        this.showUnauthorizeduserMessage = showUnauthorizeduserMessage;
    }

    public String getTheme() {
        return theme;
    }

    public void setTheme(String theme){
        this.theme = theme;
        this.persistTheme(theme);
    }   


     public String logout() {
         FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
         //System.out.println("logoutRequested");
         return "logout";
     }

    public ScheduleModel getEventModel() {
        return eventModel;
    }

    public void setEventModel(ScheduleModel eventModel) {
        this.eventModel = eventModel;
    }


    }

这是我的MasterLayout.xhtml

 <f:view>
    <!-- WelcomeBar -->
    <div id="WelcomeBar">
      <ui:include src="/resources/templates/WelcomeBar.xhtml"></ui:include>
    </div>


    <f:event listener="#{scheduler.pageOnLoad }" type="preRenderView"></f:event>



    <h:form styleClass="form" id="form1" height="30">
      <p:panel>

        <div id="Header">

          <ui:include src="/resources/templates/Header.xhtml"></ui:include>
        </div>


        <div id="content">
          <ui:insert name="content"></ui:insert>
        </div>

        <div id="Footer">
          <ui:include src="/resources/templates/Footer.xhtml"></ui:include>
        </div>

      </p:panel>
    </h:form>
  </f:view>

</h:body>

这是我的schedule.xhtml,其中包含p:schedule标签:

    <ui:composition 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" 
    template="/resources/templates/MasterLayout.xhtml"
    xmlns:p="http://primefaces.org/ui">


    <!-- Content Properties  -->
    <ui:define name="content">
        <p:schedule value="#{scheduler.eventModel}" widgetVar="myschedule">
        </p:schedule>
    </ui:define>



</ui:composition>  

仅供参考,我创建了一个简单的页面text.xhtml,它可以工作。所以它必须与我模仿的方式有关:

<h:body>
  <f:view>
    <h:form styleClass="form" id="form1" height="30">
      <p:panel>
          <f:event listener="#{scheduler.pageOnLoad }" type="preRenderView"></f:event>
          <h:outputText value="test"/>
          <p:schedule value="#{scheduler.eventModel}" widgetVar="myschedule">
          </p:schedule>
      </p:panel>
    </h:form>
 </f:view>

</h:body>   

0 个答案:

没有答案