문제

다른 백킹 빈에서 동일한 이름의 날짜를 사용하는 데 문제가 있습니다.

백킹 콩 1 :

import java.io.Serializable;
import java.util.Date;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean
@ViewScoped
public class MenuLink1BB implements Serializable {

    private static final long serialVersionUID = 4070538070773061768L;

    private String value1;

    private Date value2;

    @PostConstruct
    public void init() {
        value1 = "value 1_1";
        value2 = new Date();
    }

    public String loadView() {
        return "/test/menuLink1";
    }

    public void testMenuLink1(String value) {
        System.out.println(value);
    }

    public String getValue1() {
        return value1;
    }

    public void setValue1(String value1) {
        this.value1 = value1;
    }

    public Date getValue2() {
        return value2;
    }

    public void setValue2(Date value2) {
        this.value2 = value2;
    }
}
.

백킹 콩 2 :

import java.io.Serializable;
import java.util.Date;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean
@ViewScoped
public class MenuLink2BB implements Serializable {

    private static final long serialVersionUID = -5872644335654136327L;

    private Date value2;

    private String value3;

    @PostConstruct
    public void init() {
        value2 = new Date();
        value3 = "value 2_3";
    }

    public String loadView() {
        return "/test/menuLink2";
    }

    public void testMenuLink2(String value) {
        System.out.println(value);
    }

    public Date getValue2() {
        return value2;
    }

    public void setValue2(Date value2) {
        this.value2 = value2;
    }

    public String getValue3() {
        return value3;
    }

    public void setValue3(String value3) {
        this.value3 = value3;
    }
}
.

보기 1 :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="/WEB-INF/template/template.xhtml">
    <ui:define name="bodyContent">
        <h:form id="form">
            <p:panelGrid columns="1">
                <h:outputText value="BackingBean 1 Value 1: #{menuLink1BB.value1}" />
                <h:outputText value="BackingBean 1 Value 2: #{menuLink1BB.value2}" />
                <h:outputText value="BackingBean 2 Value 2: #{menuLink2BB.value2}" />
                <h:outputText value="BackingBean 2 Value 3: #{menuLink2BB.value3}" />
            </p:panelGrid>
        </h:form>
    </ui:define>
</ui:composition>
.

보기 2 :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="/WEB-INF/templates/template.xhtml">
    <ui:define name="bodyContent">
        <h:form id="form">
            <p:panelGrid columns="1">
                <h:outputText value="BackingBean 2 Value 2: #{menuLink2BB.value2}" />
                <h:outputText value="BackingBean 2 Value 3: #{menuLink2BB.value3}" />
                <h:outputText value="BackingBean 1 Value 1: #{menuLink1BB.value1}" />
                <h:outputText value="BackingBean 1 Value 2: #{menuLink1BB.value2}" />
            </p:panelGrid>
        </h:form>
    </ui:define>
</ui:composition>
.

보기를로드하면 다음 AJAX 오류가 표시됩니다.

firefox :

TypeError: (intermediate value).exec(...) is null
.

크롬 :

Uncaught TypeError: Cannot read property '0' of null 
.

및 마지막으로 template.xhml 파일 :

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
    <h:head>
    </h:head>
    <h:body>
        <p:panelGrid>
            <p:row>
                <p:column>
                    <h:form id="menuForm">
                        <p:panelMenu id="menuPM">
                            <p:submenu label="Menu">
                                <p:menuitem action="#{menuLink1BB.loadView}" value="Menu link 1" />
                                <p:menuitem action="#{menuLink2BB.loadView}" value="Menu link 2" />
                            </p:submenu>
                        </p:panelMenu>
                    </h:form>
                </p:column>
                <p:column>
                    <ui:insert name="dialogs" />
                    <p:messages autoUpdate="true" closable="true" redisplay="false" />
                    <ui:insert name="bodyContent" />
                </p:column>
            </p:row>
        </p:panelGrid>
    </h:body>
</f:view>
</html>
.

동일한 이름의 백업 bean의 두 개의 백업 bean에 날짜 유형의 두 가지 속성이있는 경우에만 java.util.Date 유형의 필드 만 사용합니다

도움이 되었습니까?

해결책

PrimeFaces 5.1

이므로 고정되었습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top