Author: abelevich
Date: 2007-06-13 12:28:48 -0400 (Wed, 13 Jun 2007)
New Revision: 1165
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/Messages.properties
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Key.java
Log:
add inputs to demo
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java
(rev 0)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java 2007-06-13
16:28:48 UTC (rev 1165)
@@ -0,0 +1,121 @@
+
+package org.richfaces.demo.converters;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.richfaces.demo.converters.utils.ConverterUtils;
+import org.richfaces.demo.datagrid.model.Channel;
+import org.richfaces.demo.datagrid.model.Issue;
+import org.richfaces.demo.datagrid.model.JiraUser;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class JiraUserConverter implements Converter, StateHolder {
+
+ private List <? super JiraUser> jiraUsersList = new ArrayList<JiraUser>();
+
+ private Channel channel;
+
+ private boolean transientFlag;
+
+
+ public JiraUserConverter() {
+ transientFlag = false;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException{
+
+ JiraUser user = findUser(value);
+ if( user == null){
+ FacesMessage errorMessage = ConverterUtils.createTypeErrorMessage(value,"real
jira username");
+ throw new ConverterException(errorMessage);
+ }
+ return user;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException{
+
+ JiraUser jiraUser = null;
+
+ if(value instanceof JiraUser){
+ jiraUser = (JiraUser)value;
+ }else{
+ FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
JiraUser.class.getName());
+ throw new ConverterException(errorMessage);
+ }
+
+ return jiraUser.getName();
+ }
+
+ public boolean isTransient() {
+ return transientFlag;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object [] values = (Object[])state;
+ jiraUsersList = (List<? super JiraUser>)values[0];
+ }
+
+ public Object saveState(FacesContext context) {
+ Object [] values = new Object[1];
+ values [0] = jiraUsersList;
+ return values;
+ }
+
+ public void setTransient(boolean transientFlag) {
+ this.transientFlag = transientFlag;
+ }
+
+ private void createJiraUsersList(Channel channel){
+
+ List issuesList = channel.getIssues();
+ for (Iterator iter = issuesList.iterator(); iter.hasNext();) {
+ Issue element = (Issue) iter.next();
+ JiraUser jiraUser = element.getAssignee();
+
+ if((jiraUser != null) && (!jiraUsersList.contains(jiraUser))){
+ jiraUsersList.add(jiraUser);
+ }
+ }
+ }
+
+ public JiraUser findUser(String user){
+
+ for (Iterator iter = jiraUsersList.iterator(); iter.hasNext();) {
+ JiraUser jiraUser = (JiraUser) iter.next();
+ String name = jiraUser.getName();
+ if(name != null){
+ if(name.equals(user)){
+ return jiraUser;
+ }
+
+ }
+ }
+
+ return null;
+ }
+
+ public Channel getChannel() {
+ return channel;
+ }
+
+ public void setChannel(Channel channel) {
+ this.channel = channel;
+ createJiraUsersList(channel);
+ }
+
+
+}
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java
(rev 0)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java 2007-06-13
16:28:48 UTC (rev 1165)
@@ -0,0 +1,67 @@
+package org.richfaces.demo.converters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.richfaces.demo.converters.utils.ConverterUtils;
+import org.richfaces.demo.datagrid.model.Priority;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class PriorityConverter implements Converter{
+
+ public PriorityConverter() {
+ }
+
+
+ private List prioritiesList = new ArrayList<Priority>();
+
+ public List getPrioritiesList() {
+ return prioritiesList;
+ }
+
+ public void setPrioritiesList(List prioritiesList) {
+ this.prioritiesList = prioritiesList;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException{
+
+ int id = Integer.parseInt(value);
+
+ Priority convertedValue = null;
+
+ try {
+ convertedValue = (Priority)prioritiesList.get(id);
+ } catch (IndexOutOfBoundsException e) {
+ FacesMessage errorMessage = new FacesMessage(e.getMessage());
+ errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
+ throw new ConverterException(errorMessage);
+ }
+
+ return convertedValue;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException{
+
+ Priority priority = null;
+
+ if(value instanceof Priority){
+ priority = (Priority)value;
+ }else{
+ FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
Priority.class.getName());
+ throw new ConverterException(errorMessage);
+ }
+
+ return Integer.toString(priority.getId());
+ }
+}
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java
(rev 0)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java 2007-06-13
16:28:48 UTC (rev 1165)
@@ -0,0 +1,64 @@
+package org.richfaces.demo.converters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.richfaces.demo.converters.utils.ConverterUtils;
+import org.richfaces.demo.datagrid.model.Status;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class StatusConverter implements Converter{
+
+ private List statusList = new ArrayList<Status>();
+
+
+ public List getStatusList() {
+ return statusList;
+ }
+
+ public void setStatusList(List statusList) {
+ this.statusList = statusList;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException{
+
+ Status convertedValue = null;
+ int id = Integer.parseInt(value);
+
+
+ try {
+ convertedValue = (Status)statusList.get(id);
+ } catch (IndexOutOfBoundsException e) {
+ FacesMessage errorMessage = new FacesMessage(e.getMessage());
+ errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
+ throw new ConverterException(errorMessage);
+ }
+
+ return convertedValue;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException{
+
+ Status status = null;
+
+ if(value instanceof Status){
+ status = (Status)value;
+ }else{
+ FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
Status.class.getName());
+ throw new ConverterException(errorMessage);
+ }
+
+ return Integer.toString(status.getId()) ;
+ }
+}
\ No newline at end of file
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java
(rev 0)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java 2007-06-13
16:28:48 UTC (rev 1165)
@@ -0,0 +1,19 @@
+package org.richfaces.demo.converters.utils;
+
+import javax.faces.application.FacesMessage;
+
+public class ConverterUtils {
+
+ private static final String CONVERSATION_ERROR = "Conversation error: expected
";
+
+ public static FacesMessage createTypeErrorMessage(String received, String expected ){
+
+ String summary = CONVERSATION_ERROR + expected + "found " + received;
+
+ FacesMessage errorMessage = new FacesMessage();
+ errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
+ errorMessage.setSummary(summary);
+
+ return errorMessage;
+ }
+}
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java 2007-06-13
16:27:58 UTC (rev 1164)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java 2007-06-13
16:28:48 UTC (rev 1165)
@@ -10,7 +10,11 @@
package org.richfaces.demo.datagrid.bean;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.faces.event.ActionEvent;
+import javax.faces.model.SelectItem;
import org.richfaces.demo.datagrid.model.Channel;
import org.richfaces.demo.datagrid.model.Issue;
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Key.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Key.java 2007-06-13
16:27:58 UTC (rev 1164)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Key.java 2007-06-13
16:28:48 UTC (rev 1165)
@@ -68,6 +68,6 @@
@Override
public String toString() {
- return getClass().getSimpleName() + ":" + value;
+ return String.valueOf(id);
}
}
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/Messages.properties
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/Messages.properties
(rev 0)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/resources/com/sun/el/Messages.properties 2007-06-13
16:28:48 UTC (rev 1165)
@@ -0,0 +1,84 @@
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common Development
+# and Distribution License("CDDL") (collectively, the "License").
You
+# may not use this file except in compliance with the License. You can obtain
+# a copy of the License at
https://glassfish.dev.java.net/public/CDDL+GPL.html
+# or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+# language governing permissions and limitations under the License.
+#
+# When distributing the software, include this License Header Notice in each
+# file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+# Sun designates this particular file as subject to the "Classpath" exception
+# as provided by Sun in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the License
+# Header, with the fields enclosed by brackets [] replaced by your own
+# identifying information: "Portions Copyrighted [year]
+# [name of copyright owner]"
+#
+# Contributor(s):
+#
+# If you wish your version of this file to be governed by only the CDDL or
+# only the GPL Version 2, indicate your decision by adding "[Contributor]
+# elects to include this software in this distribution under the [CDDL or GPL
+# Version 2] license." If you don't indicate a single choice of license, a
+# recipient has the option to distribute your version of this file under
+# either the CDDL, the GPL Version 2 or to extend the choice of license to
+# its licensees as provided above. However, if you add GPL Version 2 code
+# and therefore, elected the GPL Version 2 license, then the option applies
+# only if the new code is made subject to such option by the copyright
+# holder.
+#
+
+# General Errors
+error.convert=Cannot convert {0} of type {1} to {2}
+error.compare=Cannot compare {0} to {1}
+error.function=Problems calling function ''{0}''
+error.unreachable.base=Target Unreachable, identifier ''{0}'' resolved to
null
+error.unreachable.property=Target Unreachable, ''{0}'' returned null
+error.resolver.unhandled=ELResolver did not handle type: {0} with property of
''{1}''
+error.resolver.unhandled.null=ELResolver cannot handle a null base Object with identifier
''{0}''
+
+# ValueExpressionLiteral
+error.value.literal.write=ValueExpression is a literal and not writable: {0}
+
+# ExpressionFactoryImpl
+error.null=Expression cannot be null
+error.mixed=Expression cannot contain both '#{..}' and '${..}' : {0}
+error.method=Not a valid MethodExpression : {0}
+error.method.nullParms=Parameter types cannot be null
+error.value.expectedType=Expected type cannot be null
+
+# ExpressionMediator
+error.eval=Error Evaluating {0} : {1}
+
+# ValueSetVisitor
+error.syntax.set=Illegal Syntax for Set Operation
+
+# ReflectionUtil
+error.method.notfound=Method not found: {0}.{1}({2})
+error.property.notfound=Property ''{1}'' not found on {0}
+
+# ValidatingVisitor
+error.fnMapper.null=Expression uses functions, but no FunctionMapper was provided
+error.fnMapper.method=Function ''{0}'' not found
+error.fnMapper.paramcount=Function ''{0}'' specifies {1} params, but {2}
were declared
+
+# **ExpressionImpl
+error.context.null=ELContext was null
+
+# ArrayELResolver
+error.array.outofbounds=Index {0} is out of bounds for array of size {1}
+
+# ListELResolver
+error.list.outofbounds=Index {0} is out of bounds for list of size {1}
+
+# BeanELResolver
+error.property.notfound=Property ''{1}'' not found on type: {0}
+error.property.invocation=Property ''{1}'' threw an exception from type:
{0}
+error.property.notreadable=Property ''{1}'' doesn't have a
'get' specified on type: {0}
+error.property.notwritable=Property ''{1}'' doesn't have a
'set' specified on type: {0}
\ No newline at end of file