2012-06-08 4 views
0

내가 템플릿의 종류를 가지고 있고이 복합 XHTML이 예를 들어 내 XHTML 작업을 최소화하기 위해 JSF 2.0 복합을 사용하고 있습니다 :JSF2.0 복합은 전달 된 값의 각각에 대한 풍부한 탭을 추가

<?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:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:cc="http://java.sun.com/jsf/composite" 
    > 

<cc:interface> 

    <cc:attribute name="tableHeadder" /> 
    <cc:attribute name="fechaValueInicial" /> 
    <cc:attribute name="fechaValueFinal" /> 
    <cc:attribute name="nombreSelectOne" /> 
    <cc:attribute name="valueSelectOne" /> 
<cc:attribute name="valueSelectList" /> 
    <cc:attribute name="nombreCommandButton" /> 
    <cc:attribute name="firstTabName" /> 
    <cc:attribute name="firstTabValue" /> 
    <cc:attribute name="secondTabName" /> 
    <cc:attribute name="secondTabValue" /> 
    <cc:attribute name="thirdTabName" /> 
    <cc:attribute name="thirdTabValue" /> 
    <cc:attribute name="funcionCommandButton" 
     method-signature="java.lang.String action()" /> 

</cc:interface> 

<cc:implementation> 

    <a4j:status onstart="#{rich:component('statPane')}.show()" 
       onstop="#{rich:component('statPane')}.hide()" /> 

     <h:form> 

     <rich:panel header="#{cc.attrs.tableHeadder}"> 
      <rich:messages/> 

      <div> 
       <div> 
        <h:outputText value="Del:"/> 
        <rich:calendar datePattern="dd/MMMM/yyyy" popup="true" mode="ajax" 
            required="true" 
            requiredMessage="Selecciona una fecha inicial" 
            locale="es" value="#{cc.attrs.fechaValueInicial}" /> 
        <h:outputText value="Al:"/> 
        <rich:calendar datePattern="dd/MMMM/yyyy" popup="true" mode="ajax" 
            required="true" 
            requiredMessage="Selecciona una fecha final" 
            locale="es" value="#{cc.attrs.fechaValueFinal}" /> 

        <br/><br/> 

        <h:outputLabel value="#{cc.attrs.nombreSelectOne}" /> 
        <h:selectOneMenu 
         value="#{cc.attrs.valueSelectOne}"> 
         <f:selectItems value="#{cc.attrs.valueSelectList}" /> 
        </h:selectOneMenu> 
        <br/><br/> 


        <h:commandButton value="#{cc.attrs.nombreCommandButton}" actionListener="#{cc.attrs.funcionCommandButton}" /> 
       </div> 


      </div> 
      <br/><br/><br/><br/> 

      <rich:tabPanel switchType="server"> 
       <rich:tab header="#{cc.attrs.firstTabName}"> 
        <ui:include src="#{cc.attrs.firstTabValue}" /> 
       </rich:tab> 
       <rich:tab header="#{cc.attrs.secondTabName}"> 
        <ui:include src="#{cc.attrs.secondTabValue}" /> 
       </rich:tab> 
       <rich:tab header="#{cc.attrs.thirdTabName}"> 
        <ui:include src="#{cc.attrs.thirdTabValue}" /> 
       </rich:tab> 

      </rich:tabPanel> 

      <ui:include src="../../waitPopup.xhtml" /> 

     </rich:panel> 
    </h:form> 

</cc:implementation> 

과이 방법으로 구현 :

<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:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:CT="http://java.sun.com/jsf/composite/CompositeTemplates" 
    > 

<h:head> 
    <title>Reporte de Recepcion de Leche</title> 
</h:head> 

<body> 

    <CT:reportes 
     tableHeadder="Reporte Recepcion de Leche" 
     fechaValueInicial="#{lecheReporteProveedoresVB.fechaInicial}" 
     fechaValueFinal="#{lecheReporteProveedoresVB.fechaFinal}" 
     nombreSelectOne="Proveedores: " 
     valueSelectOne="#{lecheReporteProveedoresVB.proveedor}" 
     valueSelectList="#{CatalogoProveedoresLecheSI.selectList}" 
     nombreCommandButton="Consultar" 
     funcionCommandButton="#{lecheReporteProveedoresVB.consultar()}" 
     firstTabName="Recepcion por Dia" 
     firstTabValue="../../leche/lecheReporteProveedoresDia.xhtml" 
     secondTabName="Recepcion por Mes" 
     secondTabValue="../../leche/lecheReporteProveedoresMes.xhtml" 
     thirdTabName="Recepcion por Proveedores" 
     thirdTabValue="../../leche/lecheReporteProveedoresRecibido.xhtml"/> 



</body> 

내가 싶습니다을 대신 십이 첫 번째 탭을 두드 리기 두 번째 탭 세 번째 탭, 예를 들어 3 개의 첫 번째 탭 값을 제공하고 복합 요소로 3 개의 richTab 구성 요소를 만들 수 있습니다. 당신이 할 수

답변

0

잘 한 가지를 사용하고 .. 동적으로 첫 번째 방법을 탭을 만들 (그리고 당신이 향상시킬 수 있습니다 ..) 이런 일을하고있을 것입니다 .. 구성 요소에

:

<?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:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:cc="http://java.sun.com/jsf/composite" 
    > 
<cc:interface> 

    <cc:attribute name="tableHeadder" /> 
    <cc:attribute name="fechaValueInicial" /> 
    <cc:attribute name="fechaValueFinal" /> 
    <cc:attribute name="nombreSelectOne" /> 
    <cc:attribute name="valueSelectOne" /> 
<cc:attribute name="valueSelectList" /> 
    <cc:attribute name="nombreCommandButton" /> 

    <cc:attribute name="tabList" /> 

    <cc:attribute name="funcionCommandButton" 
     method-signature="java.lang.String action()" /> 

</cc:interface> 

<cc:implementation> 

    <a4j:status onstart="#{rich:component('statPane')}.show()" 
       onstop="#{rich:component('statPane')}.hide()" /> 

     <h:form> 

     <rich:panel header="#{cc.attrs.tableHeadder}"> 
      <rich:messages/> 

      <div> 
       <div> 
        <h:outputText value="Del:"/> 
        <rich:calendar datePattern="dd/MMMM/yyyy" popup="true" mode="ajax" 
            required="true" 
            requiredMessage="Selecciona una fecha inicial" 
            locale="es" value="#{cc.attrs.fechaValueInicial}" /> 
        <h:outputText value="Al:"/> 
        <rich:calendar datePattern="dd/MMMM/yyyy" popup="true" mode="ajax" 
            required="true" 
            requiredMessage="Selecciona una fecha final" 
            locale="es" value="#{cc.attrs.fechaValueFinal}" /> 

        <br/><br/> 

        <h:outputLabel value="#{cc.attrs.nombreSelectOne}" /> 
        <h:selectOneMenu 
         value="#{cc.attrs.valueSelectOne}"> 
         <f:selectItems value="#{cc.attrs.valueSelectList}" /> 
        </h:selectOneMenu> 
        <br/><br/> 


        <h:commandButton value="#{cc.attrs.nombreCommandButton}" actionListener="#{cc.attrs.funcionCommandButton}" /> 
       </div> 


      </div> 
      <br/><br/><br/><br/> 

      <rich:tabPanel switchType="server"> 
       <ui:repeat var="tab" value="#{cc.attrs.tabList}" > 
       <rich:tab header="#{tab.header}"> 
        <ui:include src="#{tab.src}" /> 
       </rich:tab> 
       </ui:repeat> 

      </rich:tabPanel> 

      <ui:include src="../../waitPopup.xhtml" /> 

     </rich:panel> 
    </h:form> 

</cc:implementation> 

공용 클래스 TabData 직렬화 {

private static final long serialVersionUID = 1L; 


    private String header; 
    private String src; 

    public TabData(String header, String src) { 
     this.header = header; 
     this.src = src; 
    } 

    /* getters & setters */ 
0을 구현

지금 ... 당신은 보유 탭 데이터를 POJO를 만들어야합니다

} 여러분의 빈에

.. 그냥 목록을 추가하고 채울 ...

... 

private List<TabData> tabs = new ArrayList<TabData>(); 

@PostConstrunct 
public void init() { 
    tabs.add(new TabData("Recepcion por Dia","../../leche/lecheReporteProveedoresDia.xhtml")); 
    ... 
} 

/* Getter & Setter */ 

을하고 구성 요소를 사용 finally..to : 내가 실제로 해본 적이

<CT:reportes 
     tableHeadder="Reporte Recepcion de Leche" 
     fechaValueInicial="#{lecheReporteProveedoresVB.fechaInicial}" 
     fechaValueFinal="#{lecheReporteProveedoresVB.fechaFinal}" 
     nombreSelectOne="Proveedores: " 
     valueSelectOne="#{lecheReporteProveedoresVB.proveedor}" 
     valueSelectList="#{CatalogoProveedoresLecheSI.selectList}" 
     nombreCommandButton="Consultar" 
     funcionCommandButton="#{lecheReporteProveedoresVB.consultar()}" 
     tabList="#{bean.tabs}" /> 

을 Richfaces로이 접근법을 사용하여 jQuery를 생성하는 데 사용했으며 잘 작동합니다 .... 그리고 다시 개선 할 수 있습니다.

감사합니다.

+0

은 완벽하게 구현되어 내일을 구현하고 여러분에게 피드백을 줄 것입니다. 저는 이미 비슷한 것을 보았습니다. 반복합니다. 반복 http://stackoverflow.com/questions/6902600/how-to-create-a -composite-component-with-dynamic-attributes? rq = 1 –

관련 문제