Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Java EE (J2EE) и Spring > seam, richfaces, управляющие теги


Автор: maratische 29.11.2008, 17:26
(в перечисленных технологиях новичек)
Есть проект на Seam (2.1.0), в нем генерится таблица документов, причем при клике на одну строку она раскрывается для редактирования, ниже есть пример с использованием тегов <rich:dataTable> <rich:column> <rich:columnGroup>
выглядит это все красиво, но работает ужасно долго.

захотелось попробовать оптимизировать и нарисовать саму таблицу (раз она такая сложная) обычными html тегами и добавить туда ajax 
но не нашел никаких управляющих тегов, те хотелось бы что то на подобие 
Код

<table width="100%" class="citable">
  <a4j:repeat value="#{templateList.templates}" var="t">
    <:if test="#{t.id == templateList.selectedTemplate.id}">
      <tr>...........</tr>
    </:if>             
  </a4j:repeat>
</table>


Есть такие теги?

И еще вопрос, на странице постоянно вызывается templateList.selectedTemplate. это не может являться тормозом и не надо заменить на какую нибудь, созданную на странице (ContextPage?) переменную? типа <:variable var="selectedTemplateId" value="#{templateList.selectedTemplate.id}" />?

Код

        <rich:dataTable var="d"
              value="#{templateList.selectedTemplate.documents}"
           rendered="#{not empty templateList.selectedTemplate.documents}"
           rowClasses="even,odd"
           styleClass="citable"
           style="citable">
       
        <rich:column
         rendered="#{templateList.selectedDocument == null or d.id != templateList.selectedDocument.id}"
         >
            <f:facet name="header">
            <h:outputText value="Production"/>
            </f:facet>
        </rich:column>
        
        <rich:column headerClass="#{templateList.sortColumn=='name' ? (templateList.orderDirection=='desc' ? 'desc' : 'asc')  : 'none'}"
             rendered="#{templateList.selectedDocument == null or d.id != templateList.selectedDocument.id}">
            <f:facet name="header">
              <s:link value="Document name">
                  <f:param name="sort" value="name" />
                    <f:param name="order" value="#{templateList.orderDirection=='asc' ? 'desc' : 'asc'}"/> 
              </s:link>
            </f:facet>
            <a4j:commandLink action="#{templateList.selectDocument(d.id)}" reRender="documentResult,breadcrumbPanel">
             <h:outputText value="#{d.name}" />
            </a4j:commandLink>    
        </rich:column>
        
        <rich:column headerClass="#{templateList.sortColumn=='approvalDate' ? (templateList.orderDirection=='desc' ? 'desc' : 'asc')  : 'none'}"
         rendered="#{templateList.selectedDocument == null or d.id != templateList.selectedDocument.id}">
            <f:facet name="header">
                <s:link value="Approval date">
                    <f:param name="sort" value="approvalDate" />
                    <f:param name="order" value="#{templateList.orderDirection=='asc' ? 'desc' : 'asc'}"/>
                </s:link>
            </f:facet>
            <h:outputText value="#{d.approved}">
             <s:convertDateTime pattern="dd.MM.yyyy"/>
            </h:outputText>
        </rich:column>
        
         <rich:column headerClass="#{templateList.sortColumn=='approvalUsere' ? (templateList.orderDirection=='desc' ? 'desc' : 'asc')  : 'none'}"
              rendered="#{templateList.selectedDocument == null or d.id != templateList.selectedDocument.id}">
            <f:facet name="header">
                <s:link value="Approval by">
                    <f:param name="sort" value="approvalBy" />
                    <f:param name="order" value="#{templateList.orderDirection=='asc' ? 'desc' : 'asc'}"/>
                </s:link>
            </f:facet>
            <h:outputText value="#{d.approvedBy}" />
        </rich:column>
        <!-- SELECTED! -->
        <rich:column
         rendered="#{templateList.selectedDocument != null and d.id == templateList.selectedDocument.id}">
            <f:facet name="header">
            <h:outputText value="Production"/>
            </f:facet>
        </rich:column>
        
        <rich:column headerClass="#{templateList.sortColumn=='name' ? (templateList.orderDirection=='desc' ? 'desc' : 'asc')  : 'none'}"
             rendered="#{templateList.selectedDocument != null and d.id == templateList.selectedDocument.id}">
            <f:facet name="header">
              <s:link value="Document name">
                  <f:param name="sort" value="name" />
                    <f:param name="order" value="#{templateList.orderDirection=='asc' ? 'desc' : 'asc'}"/> 
              </s:link>
            </f:facet>
            <h:inputText value="#{templateList.selectedDocument.name}" />
        </rich:column>
        
        <rich:column headerClass="#{templateList.sortColumn=='approvalDate' ? (templateList.orderDirection=='desc' ? 'desc' : 'asc')  : 'none'}"
         rendered="#{templateList.selectedDocument != null and d.id == templateList.selectedDocument.id}">
            <f:facet name="header">
                <s:link value="Approval date">
                    <f:param name="sort" value="approvalDate" />
                    <f:param name="order" value="#{templateList.orderDirection=='asc' ? 'desc' : 'asc'}"/>
                </s:link>
            </f:facet>
            <h:outputText value="#{d.approved}">
             <s:convertDateTime pattern="dd.MM.yyyy"/>
            </h:outputText>
        </rich:column>
        
         <rich:column headerClass="#{templateList.sortColumn=='approvalUsere' ? (templateList.orderDirection=='desc' ? 'desc' : 'asc')  : 'none'}"
              rendered="#{templateList.selectedDocument != null and d.id == templateList.selectedDocument.id}">
            <f:facet name="header">
                <s:link value="Approval by">
                    <f:param name="sort" value="approvalBy" />
                    <f:param name="order" value="#{templateList.orderDirection=='asc' ? 'desc' : 'asc'}"/>
                </s:link>
            </f:facet>
            <h:outputText value="#{d.approvedBy}" />
        </rich:column>
        <rich:columnGroup rendered="#{templateList.selectedDocument != null and d.id == templateList.selectedDocument.id}">
            <rich:column >
         </rich:column>
            <rich:column colspan="2">
             
                <table class="layout" width="100%">
                  <tr>
                    <td>Modified at</td>
                    <td>
                     <h:outputText value="#{templateList.selectedDocument.updated}">
                         <s:convertDateTime pattern="dd.MM.yyyy"/>
                     </h:outputText>
                    </td>
                    <td>by</td>
                    <td>
                     <h:outputText value="#{templateList.selectedDocument.updatedBy}" />
                    </td>
                  </tr><tr>
                    <td>Created at</td>
                    <td>
                     <h:outputText value="#{templateList.selectedDocument.created}">
                         <s:convertDateTime pattern="dd.MM.yyyy"/>
                     </h:outputText>
                    </td>
                    <td>by</td>
                    <td>
                     <h:outputText value="#{templateList.selectedDocument.createdBy}" />
                    </td>
                  </tr><tr>
                    <td colspan="4">
                      Description:<br/>
                      <h:inputTextarea value="#{templateList.selectedDocument.description}" cols="45" rows="4"/>
                    </td>
                  </tr><tr>
                    <td colspan="3"></td>
                    <td align="center">
                     <h:commandButton action="#{templateList.saveSelectedDocument()}" value="Save" styleClass="cibutton"/>
                     <h:commandButton action="#{templateList.cancelSelectedDocument()}" value="Cancel" styleClass="cibutton"/>
                    </td>
                  </tr>
                </table>
         </rich:column>
            <rich:column styleClass="b r">
             <a href="#" title="Click for preview">
               <img src="img/preview.jpg" alt="Click for preview" style="border:1px solid black; margin:10px;"/>
                </a>
         </rich:column>
        </rich:columnGroup>

        <f:facet name="footer">
         Displaying 1  - #{templateList.selectedTemplate.documents.size()} of a total of #{templateList.selectedTemplate.documents.size()}
        </f:facet>
    </rich:dataTable> 

Автор: maratische 30.11.2008, 16:31
коллега на одном из форум обнаружил прекрасное решение проблемы, через тег 
Код

<ui:fragment rendered="">
...
</ui:fragment>

который формально и является тем самым управляющим IF, что я искал.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)