myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1130226 - in /myfaces/tomahawk/trunk/sandbox/examples20/src/main: java/org/apache/myfaces/examples/listexample/ webapp/ webapp/META-INF/templates/ webapp/WEB-INF/ webapp/resources/styles/
Date Wed, 01 Jun 2011 17:06:00 GMT
Author: lu4242
Date: Wed Jun  1 17:06:00 2011
New Revision: 1130226

URL: http://svn.apache.org/viewvc?rev=1130226&view=rev
Log:
Add example mixing everything we have on sandbox right now

Added:
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerActionListener.java
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerList.java
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCar.java
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCity.java
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountry.java
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryList.java
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/dataTableAjaxEffects.xhtml
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/resources/styles/datatable.css
Modified:
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/META-INF/templates/leftmenu.xhtml
    myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/WEB-INF/examples-config.xml

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerActionListener.java?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerActionListener.java
(added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerActionListener.java
Wed Jun  1 17:06:00 2011
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+/**
+ * @author MBroekelmann
+ *
+ */
+public class DataScrollerActionListener implements ActionListener
+{
+
+    /**
+     * @see javax.faces.event.ActionListener#processAction(javax.faces.event.ActionEvent)
+     */
+    public void processAction(ActionEvent actionEvent) throws AbortProcessingException
+    {
+        System.out.println("process dataScroller ActionEvent");
+    }
+
+}

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerList.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerList.java?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerList.java
(added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/DataScrollerList.java
Wed Jun  1 17:06:00 2011
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ArrayList;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+import org.apache.myfaces.custom.datascroller.ScrollerActionEvent;
+
+/**
+ * DOCUMENT ME!
+ * @author Thomas Spiegl (latest modification by $Author: cjhoward $)
+ * @version $Revision: 796690 $ $Date: 2009-07-22 07:52:32 -0500 (mié, 22 jul 2009) $
+ */
+public class DataScrollerList
+{
+    private Integer rowCount = new Integer(10);
+
+    public Integer getRowCount() {
+        return rowCount;
+    }
+
+    public void setRowCount(Integer rowCount) {
+        this.rowCount = rowCount;
+    }
+    
+    private List _list = new ArrayList();
+
+    public DataScrollerList()
+    {
+        for (int i = 1; i < 995; i++)
+        {
+            _list.add(new SimpleCar(i, "Car Type " + i, "blue"));
+        }
+    }
+
+    public List getList()
+    {
+        return _list;
+    }
+
+    public void scrollerAction(ActionEvent event)
+    {
+        ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
+        FacesContext.getCurrentInstance().getExternalContext().log(
+                        "scrollerAction: facet: "
+                                        + scrollerEvent.getScrollerfacet()
+                                        + ", pageindex: "
+                                        + scrollerEvent.getPageIndex());
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCar.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCar.java?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCar.java
(added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCar.java
Wed Jun  1 17:06:00 2011
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.io.Serializable;
+
+/**
+ * DOCUMENT ME!
+ * @author Thomas Spiegl (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472610 $ $Date: 2006-11-08 14:46:34 -0500 (mié, 08 nov 2006) $
+ */
+public class SimpleCar
+        implements Serializable
+{
+    /**
+     * serial id for serialisation versioning
+     */
+    private static final long serialVersionUID = 1L;
+    private int _id;
+    private String _type;
+    private String _color;
+
+    public SimpleCar(int id, String type, String color)
+    {
+        _id = id;
+        _type = type;
+        _color = color;
+    }
+
+    public int getId()
+    {
+        return _id;
+    }
+
+    public void setId(int id)
+    {
+        _id = id;
+    }
+
+    public String getType()
+    {
+        return _type;
+    }
+
+    public void setType(String type)
+    {
+        _type = type;
+    }
+
+    public String getColor()
+    {
+        return _color;
+    }
+
+    public void setColor(String color)
+    {
+        _color = color;
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCity.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCity.java?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCity.java
(added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCity.java
Wed Jun  1 17:06:00 2011
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.io.Serializable;
+
+/**
+ * @author MBroekelmann
+ *
+ */
+public class SimpleCity implements Serializable
+{  
+    /**
+     * serial id for serialisation versioning
+     */
+    private static final long serialVersionUID = 1L;
+    private String mName;
+
+    private boolean selected;
+    
+    public boolean isSelected() {
+        return selected;
+    }
+
+    public void setSelected(boolean selected) {
+        this.selected = selected;
+    }
+    
+    public void unselect(){
+        setSelected(false);
+    }
+    
+
+    /**
+     * 
+     */
+    public SimpleCity(String name)
+    {
+        mName = name;
+    }
+
+    /**
+     * 
+     */
+    public SimpleCity()
+    {
+    }
+
+    /**
+     * @return Returns the name.
+     */
+    public String getName()
+    {
+        return mName;
+    }
+
+    /**
+     * @param name The name to set.
+     */
+    public void setName(String name)
+    {
+        mName = name;
+    }
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return getName();
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountry.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountry.java?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountry.java
(added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountry.java
Wed Jun  1 17:06:00 2011
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.html.HtmlDataTable;
+import javax.faces.event.ActionEvent;
+
+/**
+ * DOCUMENT ME!
+ * @author Thomas Spiegl (latest modification by $Author: skitching $)
+ * @version $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (jue, 03 jul 2008) $
+ */
+public class SimpleCountry implements Serializable
+{
+    /**
+     * serial id for serialisation versioning
+     */
+    private static final long serialVersionUID = 1L;
+    private long _id;
+    private String _name;
+    private String _isoCode;
+    private BigDecimal _size;
+    private boolean _remove = false;
+    private List _cities;
+    private String mSortCitiesColumn;
+    private boolean mIsSortCitiesAscending;
+    
+    public SimpleCountry(long id, String name, String isoCode, BigDecimal size, SimpleCity[]
cities)
+    {
+        _id = id;
+        _name = name;
+        _isoCode = isoCode;
+        _size = size;
+
+        if (cities != null)
+            _cities = new ArrayList(Arrays.asList(cities));
+        else
+            _cities = new ArrayList();
+    }
+
+    public long getId()
+    {
+        return _id;
+    }
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public String getIsoCode()
+    {
+        return _isoCode;
+    }
+
+    public BigDecimal getSize()
+    {
+        return _size;
+    }
+
+    public List getCities()
+    {
+        if (mSortCitiesColumn != null)
+        {
+            Collections.sort(_cities, new Comparator()
+            {
+                public int compare(Object arg0, Object arg1)
+                {
+                    SimpleCity lhs;
+                    SimpleCity rhs;
+                    if (isSortCitiesAscending())
+                    {
+                        lhs = (SimpleCity) arg0;
+                        rhs = (SimpleCity) arg1;
+                    }
+                    else
+                    {
+                        rhs = (SimpleCity) arg0;
+                        lhs = (SimpleCity) arg1;
+                    }
+                    String lhsName = lhs.getName();
+                    String rhsName = rhs.getName();
+                    if (lhsName != null)
+                    {
+                        if(rhsName != null)
+                        {
+                            return lhsName.compareToIgnoreCase(rhsName);
+                        }
+                        return -1;
+                    }
+                    else if (rhsName != null)
+                    {
+                        return 1;
+                    }
+                    return 0;
+                }
+            });
+        }
+        return _cities;
+    }
+
+    public void setId(long id)
+    {
+        _id = id;
+    }
+
+    public void setIsoCode(String isoCode)
+    {
+        _isoCode = isoCode;
+    }
+
+    public void setName(String name)
+    {
+        _name = name;
+    }
+
+    public void setSize(BigDecimal size)
+    {
+        _size = size;
+    }
+
+    public boolean isRemove()
+    {
+        return _remove;
+    }
+
+    public void setRemove(boolean remove)
+    {
+        _remove = remove;
+    }
+
+    public String addCity()
+    {
+        getCities().add(new SimpleCity());
+        return null;
+    }
+
+    public void deleteCity(ActionEvent ev)
+    {
+        UIData datatable = findParentHtmlDataTable(ev.getComponent());
+        getCities().remove(datatable.getRowIndex() + datatable.getFirst());
+    }
+
+    public void setSortCitiesColumn(String columnName)
+    {
+        mSortCitiesColumn = columnName;
+    }
+
+    /**
+     * @return Returns the sortCitiesColumn.
+     */
+    public String getSortCitiesColumn()
+    {
+        return mSortCitiesColumn;
+    }
+
+    public boolean isSortCitiesAscending()
+    {
+        return mIsSortCitiesAscending;
+    }
+
+    /**
+     * @param isSortCitiesAscending The isSortCitiesAscending to set.
+     */
+    public void setSortCitiesAscending(boolean isSortCitiesAscending)
+    {
+        mIsSortCitiesAscending = isSortCitiesAscending;
+    }
+
+    /**
+     * @param component
+     * @return
+     */
+    private HtmlDataTable findParentHtmlDataTable(UIComponent component)
+    {
+        if (component == null)
+        {
+            return null;
+        }
+        if (component instanceof HtmlDataTable)
+        {
+            return (HtmlDataTable) component;
+        }
+        return findParentHtmlDataTable(component.getParent());
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java
(added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java
Wed Jun  1 17:06:00 2011
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.faces.context.FacesContext;
+
+
+/**
+ * DOCUMENT ME!
+ * @author Manfred Geiler (latest modification by $Author: skitching $)
+ * @author Thomas Spiegl
+ * @version $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (jue, 03 jul 2008) $
+ */
+public class SimpleCountryForm
+{
+    private boolean renderHeader = true;
+    private boolean renderFooter = true;
+    
+    private long _id;
+    private String _name;
+    private String _isoCode;
+
+    public long getId()
+    {
+        return _id;
+    }
+
+    public void setId(long id)
+    {
+        _id = id;
+        if (_id > 0)
+        {
+            SimpleCountry simpleCountry = getList().getSimpleCountry(_id);
+            if (simpleCountry == null)
+            {
+                return;
+            }
+            _name = simpleCountry.getName();
+            _isoCode = simpleCountry.getIsoCode();
+        }
+    }
+
+    public void setIsoCode(String isoCode)
+    {
+        _isoCode = isoCode;
+    }
+
+    public String getIsoCode()
+    {
+        return _isoCode;
+    }
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public void setName(String name)
+    {
+        _name = name;
+    }
+
+    private SimpleCountry getSimpleCountry()
+    {
+        return new SimpleCountry(_id, _name, _isoCode, null, null);
+    }
+
+    public boolean isRenderFooter()
+    {
+        return renderFooter;
+    }
+
+    public void setRenderFooter(boolean renderFooter)
+    {
+        this.renderFooter = renderFooter;
+    }
+
+    public boolean isRenderHeader()
+    {
+        return renderHeader;
+    }
+
+    public void setRenderHeader(boolean renderHeader)
+    {
+        this.renderHeader = renderHeader;
+    }
+
+    public String save()
+    {
+        getList().saveSimpleCountry(getSimpleCountry());
+        return "ok_next";
+    }
+
+    public String delete()
+    {
+        getList().deleteSimpleCountry(getSimpleCountry());
+        return "ok_next";
+    }
+
+    public String apply()
+    {
+        getList().saveSimpleCountry(getSimpleCountry());
+        return "ok";
+    }
+
+    private SimpleCountryList getList()
+    {
+        Object obj = FacesContext.getCurrentInstance().getApplication().getVariableResolver()
+            .resolveVariable(FacesContext.getCurrentInstance(), "countryList");
+        return (SimpleCountryList) obj;
+
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryList.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryList.java?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryList.java
(added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryList.java
Wed Jun  1 17:06:00 2011
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialViewContext;
+import javax.faces.event.ActionEvent;
+
+import org.apache.myfaces.component.html.ext.HtmlDataTable;
+
+/**
+ * DOCUMENT ME!
+ * @author Thomas Spiegl (latest modification by $Author: skitching $)
+ * @version $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (jue, 03 jul 2008) $
+ */
+public class SimpleCountryList
+{
+    private List _countries = new ArrayList();
+    static
+    {
+    }
+
+    SimpleCountry getSimpleCountry(long id)
+    {
+        for (int i = 0; i < _countries.size(); i++)
+        {
+            SimpleCountry country = (SimpleCountry)_countries.get(i);
+            if (country.getId() == id)
+            {
+                return country;
+            }
+        }
+        return null;
+    }
+
+    long getNewSimpleCountryId()
+    {
+        long maxId = 0;
+        for (int i = 0; i < _countries.size(); i++)
+        {
+            SimpleCountry country = (SimpleCountry)_countries.get(i);
+            if (country.getId() > maxId)
+            {
+                maxId = country.getId();
+            }
+        }
+        return maxId + 1;
+    }
+
+    void saveSimpleCountry(SimpleCountry simpleCountry)
+    {
+        if (simpleCountry.getId() == 0)
+        {
+            simpleCountry.setId(getNewSimpleCountryId());
+        }
+        boolean found = false;
+        for (int i = 0; i < _countries.size(); i++)
+        {
+            SimpleCountry country = (SimpleCountry)_countries.get(i);
+            if (country.getId() == simpleCountry.getId())
+            {
+                _countries.set(i, simpleCountry);
+                found = true;
+            }
+        }
+        if (!found)
+        {
+            _countries.add(simpleCountry);
+        }
+    }
+
+    void deleteSimpleCountry(SimpleCountry simpleCountry)
+    {
+        for (int i = 0; i < _countries.size(); i++)
+        {
+            SimpleCountry country = (SimpleCountry)_countries.get(i);
+            if (country.getId() == simpleCountry.getId())
+            {
+                _countries.remove(i);
+            }
+        }
+    }
+
+    public SimpleCountryList()
+    {
+        _countries.add(new SimpleCountry(1, "AUSTRIA", "AT", new BigDecimal(123L), createCities(new
String[]{"Wien","Graz","Linz","Salzburg"})));
+        _countries.add(new SimpleCountry(2, "AZERBAIJAN", "AZ", new BigDecimal(535L), createCities(new
String[]{"Baku","Sumgait","Qabala","Agdam"})));
+        _countries.add(new SimpleCountry(3, "BAHAMAS", "BS", new BigDecimal(1345623L), createCities(new
String[]{"Nassau","Alice Town","Church Grove","West End"})));
+        _countries.add(new SimpleCountry(4, "BAHRAIN", "BH", new BigDecimal(346L), createCities(new
String[]{"Bahrain"})));
+        _countries.add(new SimpleCountry(5, "BANGLADESH", "BD", new BigDecimal(456L), createCities(new
String[]{"Chittagong","Chandpur","Bogra","Feni"})));
+        _countries.add(new SimpleCountry(6, "BARBADOS", "BB", new BigDecimal(45645L), createCities(new
String[]{"Grantley Adams"})));
+    }
+
+    /**
+     * @param names
+     * @return
+     */
+    private SimpleCity[] createCities(String[] names)
+    {
+        SimpleCity[] result = new SimpleCity[names.length];
+        for (int i = 0; i < result.length; i++)
+        {
+            result[i] = new SimpleCity(names[i]);
+        }
+        return result;
+    }
+
+    public List getCountries()
+    {
+        return _countries;
+    }
+    
+    public Map getCountryMap()
+    {
+        Map map = new HashMap();
+
+        List li = getCountries();
+
+        for (int i = 0; i < li.size(); i++)
+        {
+            SimpleCountry simpleCountry = (SimpleCountry) li.get(i);
+            map.put(simpleCountry.getIsoCode(),simpleCountry.getName());
+        }
+
+        return map;
+    }
+    
+    public void setCountries(List countries)
+    {
+        _countries = countries;
+    }
+
+    public String addCountry()
+    {
+        List list = getCountries();
+        list.add(new SimpleCountry(list.size() + 1, "", "", new BigDecimal(0), createCities(new
String[] {})));
+        return "ok";
+    }
+
+    public void deleteCountry(ActionEvent ev)
+    {
+        UIData datatable = findParentHtmlDataTable(ev.getComponent());
+        getCountries().remove(datatable.getRowIndex() + datatable.getFirst());
+    }
+
+    /**
+     * @param component
+     * @return
+     */
+    private HtmlDataTable findParentHtmlDataTable(UIComponent component)
+    {
+        if (component == null)
+        {
+            return null;
+        }
+        if (component instanceof HtmlDataTable)
+        {
+            return (HtmlDataTable) component;
+        }
+        return findParentHtmlDataTable(component.getParent());
+    }
+    
+    /*
+    public void updateRow(ActionEvent ev)
+    {
+        UIData datatable = findParentHtmlDataTable(ev.getComponent());
+        
+        int oldIndex = datatable.getRowIndex();
+        try
+        {
+            datatable.setRowIndex(datatable.getFirst());
+            PartialViewContext pvc = FacesContext.getCurrentInstance().getPartialViewContext();
+            if (!pvc.isRenderAll())
+            {
+                Collection rows = pvc.getRenderIds();
+                String idToAdd = datatable.getFacet("row").getClientId();
+                if (!rows.contains(idToAdd))
+                {
+                    rows.add(idToAdd);
+                }
+            }
+        }
+        finally
+        {
+            datatable.setRowIndex(oldIndex);
+        }
+    }*/
+}

Modified: myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/META-INF/templates/leftmenu.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/META-INF/templates/leftmenu.xhtml?rev=1130226&r1=1130225&r2=1130226&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/META-INF/templates/leftmenu.xhtml
(original)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/META-INF/templates/leftmenu.xhtml
Wed Jun  1 17:06:00 2011
@@ -10,6 +10,7 @@
 <ui:composition>
     <ul class="left_menu">
         <li class="none"><h:link outcome="home" value="Home"></h:link></li>
+        <li class="none"><h:link outcome="dataTableAjaxEffects" value="DataTable
with Ajax and Effects"></h:link></li>
         <li class="none"><h:link outcome="accordionPanel" value="s:accordionPane"></h:link></li>
         <li class="none"><h:link outcome="effectAppear" value="s:effectAppear"></h:link></li>
         <li class="none"><h:link outcome="effectBlindDown" value="s:effectBlindDown"></h:link></li>

Modified: myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/WEB-INF/examples-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/WEB-INF/examples-config.xml?rev=1130226&r1=1130225&r2=1130226&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/WEB-INF/examples-config.xml
(original)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/WEB-INF/examples-config.xml
Wed Jun  1 17:06:00 2011
@@ -1,38 +1,39 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
--->
+<!-- * Licensed to the Apache Software Foundation (ASF) under one * or more 
+  contributor license agreements. See the NOTICE file * distributed with this 
+  work for additional information * regarding copyright ownership. The ASF 
+  licenses this file * to you 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. -->
 <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
-              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
-              version="2.0">
-
-    <managed-bean>
-          <managed-bean-name>passwordStrengthBean</managed-bean-name>
-          <managed-bean-class>org.apache.myfaces.examples.passwordStrength.PasswordStrengthBean</managed-bean-class>
-          <managed-bean-scope>request</managed-bean-scope>
-     </managed-bean> 
-     
-    <managed-bean>
-          <managed-bean-name>jsCallbackFunctionBean</managed-bean-name>
-          <managed-bean-class>org.apache.myfaces.examples.jsCallbackFunction.JsCallbackFunctionBean</managed-bean-class>
-          <managed-bean-scope>request</managed-bean-scope>
-     </managed-bean> 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+  version="2.0">
+
+  <managed-bean>
+    <managed-bean-name>passwordStrengthBean</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.examples.passwordStrength.PasswordStrengthBean</managed-bean-class>
+    <managed-bean-scope>request</managed-bean-scope>
+  </managed-bean>
+
+  <managed-bean>
+    <managed-bean-name>jsCallbackFunctionBean</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.examples.jsCallbackFunction.JsCallbackFunctionBean</managed-bean-class>
+    <managed-bean-scope>request</managed-bean-scope>
+  </managed-bean>
+
+  <!-- Managed Beans for simpleList.jsp -->
+
+  <managed-bean>
+    <managed-bean-name>countryList</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.examples.listexample.SimpleCountryList</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
 
 </faces-config>
 

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/dataTableAjaxEffects.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/dataTableAjaxEffects.xhtml?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/dataTableAjaxEffects.xhtml (added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/dataTableAjaxEffects.xhtml Wed
Jun  1 17:06:00 2011
@@ -0,0 +1,122 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+        xmlns:t="http://myfaces.apache.org/tomahawk"
+        xmlns:s="http://myfaces.apache.org/sandbox"
+        xmlns:mc="http://myfaces.apache.org/commons/components">
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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>
+<ui:composition template="/META-INF/templates/example_template.xhtml">
+    <ui:define name="main_content">
+      <h:outputStylesheet library="styles" name="datatable.css"/>
+      <h:form id="mainForm">
+        <h:panelGroup id="idbody">
+            <p>This example shows an ajaxified t:dataTable detailStamp, using f:ajax,
s:effectXXX and s:jsOnEventAjax.
+            With this strategy you have full control about what's going on in the dataTable.
+            </p>
+            <p>In this way you can make your applications looks better with just some
few steps, and note this will
+            work for any jsf component library, because this is all based on JSF 2.0 client
behavior standard feature.
+            </p>
+            <p>Note the javascript functions are outside the area updated by the ajax
request.  
+            </p>
+            <br/>
+           
+            <t:dataTable id="data" styleClass="standardTable" headerClass="standardTable_Header"
footerClass="standardTable_Header"
+                     rowClasses="standardTable_Row1,standardTable_Row2"
+                     columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
var="currentCountry"
+                     value="#{countryList.countries}" preserveDataModel="true" varDetailToggler="detailToggler"
ajaxRowRender="true"
+                     >
+            <h:column>
+                <f:facet name="header">
+                    <h:outputText value="Country"/>
+                </f:facet>
+                <h:outputText value="#{currentCountry.name}"/>
+            </h:column>
+        
+            <h:column>
+                <f:facet name="header">
+                    <h:outputText value="ISO"/>
+                </f:facet>
+                <h:outputText value="#{currentCountry.isoCode}"/>
+            </h:column>
+        
+            <h:column>
+                <f:facet name="header">
+                    <h:outputText value="Cities"/>
+                </f:facet>
+                <!-- Js code for hide, note some effects does not work well on tables,
so we hide the inner panel -->
+                <s:jsOnEventAjax id="jsHide" eventName="action">
+                    <s:effectSlideUp forId="citiesPanel" event="action" afterFinish="#{s:jsCallbackFunctionName(component,'jsHideRow')}"/>
+                </s:jsOnEventAjax>
+                <!-- this eliminate space occupied by detailStampRow -->
+                <s:jsCallbackFunction id="jsHideRow" eventName="action">
+                    <s:effectHide forId="detailStampRow" event="action"/>
+                </s:jsCallbackFunction>
+                
+                <!-- Js code for show, note some effects does not work well on tables,
so we hide the inner panel -->
+                <s:jsOnEventAjax id="jsShow" eventName="action">
+                  <s:effectSlideDown forId="citiesPanel" event="action" />
+                </s:jsOnEventAjax>
+                
+                <t:div id="panel">
+                  <h:commandLink id="hide" rendered="#{detailToggler.currentDetailExpanded}"
action="#{detailToggler.toggleDetail}">
+                    <h:outputText value="Hide"/>
+                    <f:ajax render="panel" onevent="#{s:jsCallbackFunctionName(component,'jsHide')}"/>
+                  </h:commandLink>
+                  <h:commandLink id="show" rendered="#{!detailToggler.currentDetailExpanded}"
action="#{detailToggler.toggleDetail}">
+                      <h:outputText value="Show"/>
+                      <f:ajax render="panel detailStampRow" onevent="#{s:jsCallbackFunctionName(component,'jsShow')}"/>
+                  </h:commandLink>
+                </t:div>
+            </h:column>
+            <f:facet name="detailStamp">
+              <!-- Note the style="display:none is for hide it after ajax, later it will
be shown by the effect." -->
+              <t:div id="citiesPanel" style="#{detailToggler.currentDetailExpanded ? 'display:none'
: ''}">
+                <t:dataTable id="cities" styleClass="standardTable_Column" var="city"
value="#{currentCountry.cities}">
+                    <h:column>
+                        <h:outputText value="#{city}" style="font-size: 11px"/>
+                    </h:column>
+                    <h:column>
+                        <h:selectBooleanCheckbox id="selcity" value="#{city.selected}"
onclick="this.blur();">
+                            <f:ajax/>
+                        </h:selectBooleanCheckbox>
+                    </h:column>
+                    <h:column>
+                        <h:commandLink action="#{city.unselect}" value="Unselect">
+                            <f:ajax execute="@this" render="cities"></f:ajax>
+                        </h:commandLink>
+                    </h:column>
+                </t:dataTable>
+              </t:div>
+            </f:facet>
+        </t:dataTable>
+        
+        </h:panelGroup>
+      </h:form>
+  </ui:define>
+ </ui:composition>
+</body>
+</html>

Added: myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/resources/styles/datatable.css
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/resources/styles/datatable.css?rev=1130226&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/resources/styles/datatable.css
(added)
+++ myfaces/tomahawk/trunk/sandbox/examples20/src/main/webapp/resources/styles/datatable.css
Wed Jun  1 17:06:00 2011
@@ -0,0 +1,44 @@
+.standardTable {
+    font-family : verdana, Geneva, Arial, Helvetica, sans-serif;
+    font-size: 12px;
+    color: #000000;
+    padding: 2;
+    border-style: solid;
+    border-width: 1px;
+}
+
+.standardTable_Header {
+    color: #000000;
+    background-color: #FFDD00;
+    padding: 3;
+    text-align: center;
+    border: none;
+}
+
+.standardTable_SortHeader {
+    background-color: #FFDD00;
+    color: #000000;
+    padding: 3;
+    text-align: center;
+    border: none;
+    font-weight: bold;
+}
+
+.standardTable_Footer {
+    background-color: #FFFFE0;
+}
+
+.standardTable_Row1 {
+    background-color: #FFFFE0;
+}
+
+.standardTable_Row2 {
+    background-color: #FFFFE0;
+}
+
+.standardTable_Column {
+}
+
+.standardTable_ColumnCentered {
+    text-align: center
+}
\ No newline at end of file



Mime
View raw message