0

4 和 JSF 2.1 , Tomcat6 的示例应用程序。单击 ui:composition 中的图像时,我试图显示一个对话框。但它没有得到显示。如果我在不使用 ui:composition> 的情况下运行它,它工作正常。

这是我的代码

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <script type="text/javascript" src="scripts/jquery-1.7.1.min.js"></script> 
</h:head>
<h:body>
<p:dialog id="dialog" header="Login" widgetVar="dlg">  
    <h:form>
    <h:outputText value="hi"></h:outputText>

    <!-- <h:panelGrid columns="2" cellspacing="5" >
        <h:outputLabel value="OsName" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.osName}"></h:inputText>

        <h:outputLabel value="OsFamily" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.osFamily}"></h:inputText>

        <h:outputLabel value="OsDescription" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.osDescription}"></h:inputText>

        <h:outputLabel value="OsGuid" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.osGuid}"></h:inputText>

        <h:outputLabel value="MajorVersion" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.majorVersion}"></h:inputText>

        <h:outputLabel value="minorVersion" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.minorVersion}"></h:inputText>

        <h:outputLabel value="BuildVersion" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.buildVersion}"></h:inputText>

        <h:outputLabel value="OsServicepack" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.osServicepack}"></h:inputText>

        <h:outputLabel value="OsRevision" style="color:black"></h:outputLabel>
        <h:inputText value="#{productBean.osRevision}"></h:inputText>



        <h:commandButton value="Back" action="#{productBean.product}" styleClass="button1" ></h:commandButton>
        <h:commandButton value="Next" action="#{productBean.productcustomer}" styleClass="button1" ></h:commandButton>
    </h:panelGrid>
     -->
    </h:form>
</p:dialog>  

<ui:composition template="/pages/templates/layout.xhtml">
            <ui:define name="body" >
    <h:form prependId="false">
    <div class="widget">

  <p:dataTable var="car"   paginator="true" rows="10" >  


        <f:facet name="header">  
            List of Cars  
        </f:facet>  


         <p:columnGroup type="header">  
            <p:row styleClass="edit">  
                <p:column rowspan="3" headerText="Model" sortBy="Model" filterBy="Model" width="" /> 
                <p:column rowspan="3" headerText="Year" sortBy="Year" filterBy="Year"/>
                <p:column rowspan="3" headerText="Company" sortBy="Company" filterBy="Company"/>
                <p:column rowspan="3" headerText="Color" sortBy="Color" filterBy="Color"/>
                <p:column colspan="3" headerText="Actions" />
            </p:row>  


            <p:row styleClass="edit">  
                <p:column><f:facet name="header"><h:outputLink  onclick="showStatus()" title="Edit">
        <p:graphicImage  value="/images/b_edit.png" /></h:outputLink>
    </f:facet></p:column>    
                <p:column><f:facet name="header"><h:outputLink  onclick="showStatus()" title="Delete">
        <p:graphicImage  value="/images/b_drop.png" /></h:outputLink>
    </f:facet></p:column> 
                <p:column><f:facet name="header"><h:outputLink  onclick="dlg.show()" title="View">
        <p:graphicImage  value="/images/search-icon.png" /></h:outputLink>
    </f:facet></p:column> 
            </p:row> 



        </p:columnGroup> 


   </p:dataTable>
   </div>
   </h:form>



   </ui:define>


 </ui:composition>




</h:body>

</html>
4

2 回答 2

1

Facelets 会跳过<ui:composition>标签之外的所有内容,因此在这种情况下对话框将不会出现在视图中。您还需要将其放在<ui:composition>标签中

于 2013-01-03T12:10:48.037 回答
-1

您好,通过将其与布尔变量绑定来尝试呈现的属性。谢谢

于 2013-01-04T11:02:23.170 回答