myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: incubator-myfaces/webapps/src/example/org/apache/myfaces/examples/listexample PagedSortableCarList.java
Date Tue, 12 Apr 2005 20:32:34 GMT
schof       2005/04/12 13:32:34

  Modified:    webapps/simple/WEB-INF examples-config.xml
               webapps/simple home.jsp
  Added:       webapps/simple jscookmenu.jsp masterDetail.jsp
                        pagedSortTable.jsp
               webapps/src/example/org/apache/myfaces/examples/listexample
                        PagedSortableCarList.java
  Removed:     webapps/simple dataTable.jsp
  Log:
  reorganized dataTable examples; added new pagedSortTable example (Chris Barlow); added new
jscookmenu example (David Heffelfinger)
  
  Revision  Changes    Path
  1.4       +6 -0      incubator-myfaces/webapps/simple/WEB-INF/examples-config.xml
  
  Index: examples-config.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/simple/WEB-INF/examples-config.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- examples-config.xml	26 Mar 2005 20:31:37 -0000	1.3
  +++ examples-config.xml	12 Apr 2005 20:32:33 -0000	1.4
  @@ -244,7 +244,13 @@
           <managed-bean-scope>session</managed-bean-scope>
       </managed-bean>
   
  +    <!-- Managed Beans for pagedSortTable.jsp -->
   
  +    <managed-bean>
  +        <managed-bean-name>pagedSort</managed-bean-name>
  +        <managed-bean-class>org.apache.myfaces.examples.listexample.PagedSortableCarList</managed-bean-class>
  +        <managed-bean-scope>session</managed-bean-scope>
  +    </managed-bean>
   
       <navigation-rule>
           <navigation-case>
  
  
  
  1.3       +6 -3      incubator-myfaces/webapps/simple/home.jsp
  
  Index: home.jsp
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/simple/home.jsp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- home.jsp	26 Mar 2005 20:31:37 -0000	1.2
  +++ home.jsp	12 Apr 2005 20:32:33 -0000	1.3
  @@ -25,13 +25,17 @@
           <h:outputLink value="sample2.jsf" ><f:verbatim>Sample 2</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="validate.jsf" ><f:verbatim>Validations</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="aliasBean.jsf" ><f:verbatim>Alias Bean</f:verbatim></h:outputLink>
<br/>
  -        <h:outputLink value="dataTable.jsf" ><f:verbatim>Master/Detail Example</f:verbatim></h:outputLink>
<br/>
  -        <h:outputLink value="sortTable.jsf" ><f:verbatim>Sortable Table</f:verbatim></h:outputLink>
<br/>
  +        Data Table<br/>
  +        &nbsp;&nbsp;&nbsp;<h:outputLink value="masterDetail.jsf" ><f:verbatim>Master-Detail</f:verbatim></h:outputLink><br/>
  +        &nbsp;&nbsp;&nbsp;<h:outputLink value="dataScroller.jsf" ><f:verbatim>Data
Scroller</f:verbatim></h:outputLink><br/>            
  +        &nbsp;&nbsp;&nbsp;<h:outputLink value="sortTable.jsf" ><f:verbatim>Sortable</f:verbatim></h:outputLink><br/>
           
  +        &nbsp;&nbsp;&nbsp;<h:outputLink value="pagedSortTable.jsf" ><f:verbatim>Paged
and Sortable</f:verbatim></h:outputLink><br/>            
           <h:outputLink value="selectbox.jsf" ><f:verbatim>Select boxes</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="fileupload.jsf" ><f:verbatim>File upload</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="tabbedPane.jsf" ><f:verbatim>Tabbed Pane</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="calendar.jsf" ><f:verbatim>Calendar</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="popup.jsf" ><f:verbatim>Popup</f:verbatim></h:outputLink>
<br/>
  +        <h:outputLink value="jscookmenu.jsf" ><f:verbatim>JSCookMenu</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="jslistener.jsf" ><f:verbatim>Javascript Listener</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="date.jsf" ><f:verbatim>Date</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="inputHtml.jsf" ><f:verbatim>Html Editor</f:verbatim></h:outputLink>
<br/>
  @@ -40,7 +44,6 @@
           <h:outputLink value="treeTable.jsf" ><f:verbatim>Tree Table</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="tree2.jsf" ><f:verbatim>Tree2</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="rssTicker.jsf" ><f:verbatim>RSS Ticker</f:verbatim></h:outputLink>
<br/>
  -        <h:outputLink value="buffer.jsf" ><f:verbatim>Data Scroller</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="panelstack.jsf" ><f:verbatim>Panel Stack</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="css.jsf" ><f:verbatim>Style Sheet</f:verbatim></h:outputLink>
<br/>
           <h:outputLink value="newspaperTable.jsf" ><f:verbatim>Newspaper Table</f:verbatim></h:outputLink>
<br/>
  
  
  
  1.1                  incubator-myfaces/webapps/simple/jscookmenu.jsp
  
  Index: jscookmenu.jsp
  ===================================================================
  
  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
  <%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
  
  <html>
  
  <%@include file="inc/head.inc"%>
  
  <!--
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  //-->
  
  <body>
  <f:view>
  	<f:loadBundle
  		basename="org.apache.myfaces.examples.resource.example_messages"
  		var="example_messages" />
  	<x:jscookMenu layout="hbr" theme="ThemeOffice">
  		<%/* Availaible jscookMenu themes: ThemeIE, ThemeMiniBlack, ThemeOffice, ThemePanel
               Availaible jscookMenu layout: hbr, hbl, hur, hul, vbr, vbl, vur, vul
               respect to Heng Yuan http://www.cs.ucla.edu/~heng/JSCookMenu
          */%>
  		<x:navigationMenuItem id="nav_1"
  			itemLabel="#{example_messages['nav_Home']}" action="go_home" />
  		<x:navigationMenuItem id="nav_2"
  			itemLabel="#{example_messages['nav_Examples']}">
  			<x:navigationMenuItem id="nav_2_1"
  				itemLabel="#{example_messages['nav_Sample_1']}" action="go_sample1" />
  			<x:navigationMenuItem id="nav_2_2"
  				itemLabel="#{example_messages['nav_Sample_2']}" action="go_sample2"
  				icon="images/myfaces.gif" />
  			<x:navigationMenuItem id="nav_2_3"
  				itemLabel="#{example_messages['nav_Validate']}" action="go_validate"
  				icon="images/myfaces.gif" />
  			<x:navigationMenuItem id="nav_2_4"
  				itemLabel="#{example_messages['nav_Components']}"
  				icon="images/component.gif" split="true">
  				<x:navigationMenuItem id="nav_2_4_1"
  					itemLabel="#{example_messages['nav_sortTable']}"
  					action="go_sortTable" icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_2"
  					itemLabel="#{example_messages['nav_Selectbox']}"
  					action="go_selectbox" icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_3"
  					itemLabel="#{example_messages['nav_FileUpload']}"
  					action="go_fileupload" icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_4"
  					itemLabel="#{example_messages['nav_TabbedPane']}"
  					action="go_tabbedPane" icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_5"
  					itemLabel="#{example_messages['nav_Calendar']}"
  					action="go_calendar" icon="images/myfaces.gif" split="true" />
  				<x:navigationMenuItem id="nav_2_4_6"
  					itemLabel="#{example_messages['nav_Popup']}" action="go_popup"
  					icon="images/myfaces.gif" split="true" />
  				<x:navigationMenuItem id="nav_2_4_7"
  					itemLabel="#{example_messages['nav_Date']}" action="go_date"
  					icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_8"
  					itemLabel="#{example_messages['nav_InputHtml']}"
  					action="go_inputHtml" icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_9"
  					itemLabel="#{example_messages['nav_tree2']}" action="go_tree2"
  					icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_10"
  					itemLabel="#{example_messages['nav_treeTable']}"
  					action="go_treeTable" icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_11"
  					itemLabel="#{example_messages['nav_rssTicker']}"
  					action="go_rssticker" icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_12"
  					itemLabel="#{example_messages['nav_dataScroller']}"
  					action="go_datascroller" icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_13"
  					itemLabel="#{example_messages['nav_css']}" action="go_css"
  					icon="images/myfaces.gif" />
  				<x:navigationMenuItem id="nav_2_4_14"
  					itemLabel="#{example_messages['nav_newspaperTable']}"
  					action="go_newspaperTable" icon="images/myfaces.gif" />
  			</x:navigationMenuItem>
  		</x:navigationMenuItem>
  	</x:jscookMenu>
  </f:view>
  <%@include file="inc/page_footer.jsp"%>
  
  </body>
  
  </html>
  
  
  
  1.1                  incubator-myfaces/webapps/simple/masterDetail.jsp
  
  Index: masterDetail.jsp
  ===================================================================
  <%@ page session="false" contentType="text/html;charset=utf-8"%>
  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
  <%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
  <html>
  
  <!--
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  //-->
  
  <%@include file="inc/head.inc" %>
  
  <body>
  
  <f:view>
  
      <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
  
      <h:panelGroup id="body">
  
         <h:panelGrid columns="1">
             <h:commandLink action="go_country" immediate="true">
                  <h:outputText value="#{example_messages['new_country']}" styleClass="standard"
/>
             </h:commandLink>
             <h:commandLink action="go_edit_table" immediate="true">
                  <h:outputText value="#{example_messages['country_edit_table']}" styleClass="standard"
/>
             </h:commandLink>
         </h:panelGrid>
         <f:verbatim><br></f:verbatim>
  
          <x:dataTable id="data"
                  styleClass="standardTable"
                  headerClass="standardTable_Header"
                  footerClass="standardTable_Header"
                  rowClasses="standardTable_Row1,standardTable_Row2"
                  columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
                  var="country"
                  value="#{countryList.countries}"
                  preserveDataModel="true" >
             <h:column>
                 <f:facet name="header">
                    <h:outputText value="#{example_messages['label_country_name']}" />
                 </f:facet>
                 <x:commandLink action="go_country" immediate="true" >
                      <h:outputText value="#{country.name}" />
                      <!-- for convenience: MyFaces extension. sets id of current row in
countryForm -->
                      <!-- you don't have to implement a custom action! -->
                      <x:updateActionListener property="#{countryForm.id}" value="#{country.id}"
/>
                 </x:commandLink>
             </h:column>
  
             <h:column>
                 <f:facet name="header">
                    <h:outputText value="#{example_messages['label_country_iso']}" />
                 </f:facet>
                 <h:outputText value="#{country.isoCode}" />
             </h:column>
  
             <h:column>
                 <f:facet name="header">
                    <h:outputText value="#{example_messages['label_country_cities']}" />
                 </f:facet>
                  <x:dataTable id="cities"
                          styleClass="standardTable_Column"
                          var="city"
                          value="#{country.cities}"
                          preserveDataModel="false">
                     <h:column>
                         <h:outputText value="#{city}" style="font-size: 11px" />
                     </h:column>
                  </x:dataTable>
             </h:column>
  
          </x:dataTable>
  
          <f:verbatim><br></f:verbatim>
  
      </h:panelGroup>
  
  </f:view>
  
  <%@include file="inc/page_footer.jsp" %>
  
  </body>
  
  </html>
  
  
  
  1.1                  incubator-myfaces/webapps/simple/pagedSortTable.jsp
  
  Index: pagedSortTable.jsp
  ===================================================================
  <%@ page session="false" contentType="text/html;charset=utf-8"%>
  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
  <%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
  <html>
  
  <!--
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  //-->
  
  <%@include file="inc/head.inc" %>
  
  <body>
  
  <!--
  managed beans used:
      countryList
  -->
  
  <f:view>
  
      <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
  
       <x:dataTable id="data"
                    styleClass="scrollerTable"
                    headerClass="standardTable_Header"
                    footerClass="standardTable_Header"
                    rowClasses="standardTable_Row1,standardTable_Row2"
                    columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
                    var="car"
                    value="#{pagedSort.cars}"
                    preserveDataModel="true"
                    rows="10"
                    sortColumn="#{pagedSort.sort}"
                    sortAscending="#{pagedSort.ascending}"
                    preserveSort="true">
          <h:column>
              <f:facet name="header"></f:facet>
              <h:outputText value="#{car.id}" />
          </h:column>
          <h:column>
              <f:facet name="header">
                  <x:commandSortHeader columnName="type" arrow="true">
                      <h:outputText value="#{example_messages['sort_cartype']}" />
                  </x:commandSortHeader>
              </f:facet>
              <h:outputText value="#{car.type}" />
          </h:column>
          <h:column>
              <f:facet name="header">
                  <x:commandSortHeader columnName="color" arrow="true">
                      <h:outputText value="#{example_messages['sort_carcolor']}" />
                  </x:commandSortHeader>
              </f:facet>
              <h:outputText value="#{car.color}" />
          </h:column>
      </x:dataTable>
  
      <h:panelGrid columns="1" styleClass="scrollerTable2" columnClasses="standardTable_ColumnCentered"
>
          <x:dataScroller id="scroll_1"
                          for="data"
                          fastStep="10"
                          pageCountVar="pageCount"
                          pageIndexVar="pageIndex"
                          styleClass="scroller"
                          paginator="true"
                          paginatorMaxPages="9"
                          paginatorTableClass="paginator"
                          paginatorActiveColumnStyle="font-weight:bold;">
              <f:facet name="first" >
                  <h:graphicImage url="images/arrow-first.gif" border="1" />
              </f:facet>
              <f:facet name="last">
                  <h:graphicImage url="images/arrow-last.gif" border="1" />
              </f:facet>
              <f:facet name="previous">
                  <h:graphicImage url="images/arrow-previous.gif" border="1" />
              </f:facet>
              <f:facet name="next">
                  <h:graphicImage url="images/arrow-next.gif" border="1" />
              </f:facet>
              <f:facet name="fastforward">
                  <h:graphicImage url="images/arrow-ff.gif" border="1" />
              </f:facet>
              <f:facet name="fastrewind">
                  <h:graphicImage url="images/arrow-fr.gif" border="1" />
              </f:facet>
          </x:dataScroller>
  
      </h:panelGrid>
  
  </f:view>
  
  <%@include file="inc/page_footer.jsp" %>
  
  </body>
  
  </html>
  
  
  
  1.1                  incubator-myfaces/webapps/src/example/org/apache/myfaces/examples/listexample/PagedSortableCarList.java
  
  Index: PagedSortableCarList.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.myfaces.examples.listexample;
  
  import java.util.*;
  
  public class PagedSortableCarList extends SortableList
  {
      private List cars = new ArrayList();
  
      public PagedSortableCarList()
      {
          super("type");
          for (int i = 100; i < 900; i++)
          {
              cars.add(new SimpleCar(i, "Car Type " + i, (i%2==0) ? "blue" : "green"));
          }
      }
  
      public List getCars()
      {
          sort(getSort(), isAscending());
          return cars;
      }
  
      protected boolean isDefaultAscending(String sortColumn)
      {
          return true;
      }
  
      protected void sort(final String column, final boolean ascending)
      {
          Comparator comparator = new Comparator()
          {
              public int compare(Object o1, Object o2)
              {
                  SimpleCar c1 = (SimpleCar)o1;
                  SimpleCar c2 = (SimpleCar)o2;
                  if (column == null)
                  {
                      return 0;
                  }
                  if (column.equals("type"))
                  {
                      return ascending ? c1.getType().compareTo(c2.getType()) : c2.getType().compareTo(c1.getType());
                  }
                  else if (column.equals("color"))
                  {
                      return ascending ? c1.getColor().compareTo(c2.getColor()) : c2.getColor().compareTo(c1.getColor());
                  }
                  else return 0;
              }
          };
          Collections.sort(cars, comparator);
      }
  
  }
  
  
  

Mime
View raw message