[jboss-cvs] jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component ...

Peter Muir peter at bleepbleep.org.uk
Tue Mar 20 13:58:58 EDT 2007


  User: pmuir   
  Date: 07/03/20 13:58:58

  Added:       seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component                 
                        UIEnumItem.java UIConversationPropagation.java
                        UISelectItems.java UITaskId.java
                        UISeamCommandBase.java UIDiv.java
                        UIConversationIsLongRunning.java UIFileUpload.java
                        UIButton.java UICache.java UIConversationId.java
                        UILink.java UIValidateAll.java UIMessage.java
                        UIAction.java UISpan.java UISelection.java
  Log:
  Port more tags to CDK
  
  Revision  Changes    Path
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIEnumItem.java
  
  Index: UIEnumItem.java
  ===================================================================
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UISelectItem;
  import javax.faces.model.SelectItem;
  
  /**
   * JSF component class
   * 
   */
  public abstract class UIEnumItem extends UISelectItem
  {
  
     private static final String COMPONENT_TYPE = "org.jboss.seam.ui.EnumItem";
  
     private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.EnumItem";
  
     public abstract String getEnumValue();
  
     public abstract void setEnumValue(String enumValue);
     
     public abstract void setLabel(String label);
     
     public abstract String getLabel();
  
     @Override
     public Object getValue()
     {
        Class c = getParent().getValueBinding("value").getType(getFacesContext());
        String enumValue = getEnumValue();
        String label = getLabel();
        Object value = Enum.valueOf(c, enumValue);
        return new SelectItem(value, label == null ? enumValue : label);
     }
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIConversationPropagation.java
  
  Index: UIConversationPropagation.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIParameter;
  import javax.faces.context.FacesContext;
  
  /**
   * JSF component class
   *
   */
  public class UIConversationPropagation extends UIParameter {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.ConversationPropagation";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.ConversationPropagation";
  
     @Override
     public String getFamily()
     {
        return COMPONENT_FAMILY;
     }
     
     private String pageflow;
     private String type = "none";
     
     @Override
     public String getName()
     {
        return "conversationPropagation";
     }
  
     @Override
     public Object getValue()
     {
        return pageflow==null ? type : type + "." + pageflow;
     }
  
     public String getPageflow()
     {
        return pageflow;
     }
  
     public void setPageflow(String pageflow)
     {
        this.pageflow = pageflow;
     }
  
     public String getType()
     {
        return type;
     }
  
     public void setType(String type)
     {
        this.type = type;
     }
  
     @Override
     public void restoreState(FacesContext context, Object state) {
        Object[] values = (Object[]) state;
        super.restoreState(context, values[0]);
        type = (String) values[1];
        pageflow = (String) values[2];
     }
  
     @Override
     public Object saveState(FacesContext context) {
        Object[] values = new Object[3];
        values[0] = super.saveState(context);
        values[1] = type;
        values[2] = pageflow;
        return values;
     }
     
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UISelectItems.java
  
  Index: UISelectItems.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import java.lang.reflect.Array;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  
  import javax.faces.FacesException;
  import javax.faces.component.ValueHolder;
  import javax.faces.convert.Converter;
  import javax.faces.el.ValueBinding;
  import javax.faces.model.DataModel;
  
  import org.jboss.seam.framework.EntityQuery;
  import org.jboss.seam.ui.converter.ConverterChain;
  import org.jboss.seam.ui.converter.NoSelectionConverter;
  
  
  /**
   * JSF component class
   *
   */
  public abstract class UISelectItems extends javax.faces.component.UISelectItems {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.SelectItems";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.SelectItems";
     
     private class NullableSelectItem extends javax.faces.model.SelectItem
     {
  
        private Object value;
  
        private NullableSelectItem(Object value, String label)
        {
           super.setLabel(label);
           this.value = value;
        }
  
        @Override
        public Object getValue()
        {
           return value;
        }
  
     }
  
     private static final String NO_SELECTION_VALUE = null;
  
     public abstract void setHideNoSelectionLabel(Boolean hideNoSelectionLabel);
     
     public abstract Boolean getHideNoSelectionLabel();
     
     public abstract String getNoSelectionLabel();
     
     public abstract void setNoSelectionLabel(String noSelectionLabel);
     
     public abstract String getVar();
     
     public abstract void setVar(String var);
     
     public abstract String getLabel();
     
     public abstract void setLabel(String label);
     
     public abstract Boolean getDisabled();
     
     public abstract void setDisabled(Boolean disabled);
  
     @Override
     public Object getValue()
     {
        Object value = super.getValue();
        
        if (value instanceof Iterable)
        {
           return asSelectItems((Iterable) value);
        }
        else if (value instanceof DataModel && ((DataModel) value).getWrappedData() instanceof Iterable)
        {
           return asSelectItems((Iterable) ((DataModel) value).getWrappedData()); 
        }
        else if (value instanceof EntityQuery)
        {
           return asSelectItems(((EntityQuery) value).getResultList());
        }
        else if (value != null && value.getClass().isArray())
        {
           if (value.getClass().getComponentType().isPrimitive())
           {
              List list = new ArrayList();
              for (int i = 0; i < Array.getLength(value); i++)
              {
                 list.add(Array.get(value, i));
              }
              return asSelectItems(list);
           }
           else
           {
              return asSelectItems(Arrays.asList((Object[]) value));
           }
        }
        else
        {
           javax.faces.model.SelectItem noSelectionLabel = noSelectionLabel();
           if (noSelectionLabel != null) 
           {
              List<javax.faces.model.SelectItem> selectItems = new ArrayList<javax.faces.model.SelectItem>();
              selectItems.add(noSelectionLabel);
              return selectItems;
           }
           else 
           {
              return value;
           }
        }
     }
     
     private List<javax.faces.model.SelectItem> asSelectItems(Iterable iterable) 
     {
        List<javax.faces.model.SelectItem> selectItems =  new ArrayList<javax.faces.model.SelectItem>();
        javax.faces.model.SelectItem noSelectionLabel = noSelectionLabel();
        if (noSelectionLabel != null) 
        {
           selectItems.add(noSelectionLabel);
        }
        for (Object o : iterable)
        {
           initVar(o);
           selectItems.add(new javax.faces.model.SelectItem(o, getLabel(), "", getDisabled() == null ? false : getDisabled()));
           destroyVar();
        }
        return selectItems;
     }
  
     private javax.faces.model.SelectItem noSelectionLabel()
     {
        boolean show = false;
        /*
         * This is a slight hack. If you do an EL expresison like this (to hide the label)
         * 
         * noSelectionLabel="#{x eq y ? 'Please Select' : null}"
         * 
         * then, if x != y, EL will return an empty String, not null, so we work around that, with the side effect
         * that if the result of the EL expression is an empty String, then the label will be hidden.
         */
        ValueBinding vb = getValueBinding("noSelectionLabel");
        if (vb == null && !(getHideNoSelectionLabel() && getParentValue() != null))
        {
           /* 
            * Here, the user has specfied a noSelectionLabel (may be an empty string), and, if hideNoSelectionLabel
            * is set, then, if a value is selected, then the label is hidden
            */ 
           show = true;
        } 
        else if (getNoSelectionLabel() != null && !"".equals(getNoSelectionLabel()) && !(getHideNoSelectionLabel() && getParentValue() != null))
        {
           /*
            * Here, the user has used an EL expression as the noSelectionLabel.  In this case, an empty string is
            * indicates that the label should be hidden.
            */
           show = true;
        }
        
        if (show)
        {
           NullableSelectItem s = new NullableSelectItem(NO_SELECTION_VALUE, getNoSelectionLabel());
           ConverterChain converterChain = new ConverterChain(this.getParent());
           Converter noSelectionConverter = new NoSelectionConverter();
           // Make sure that the converter is only added once
           if (!converterChain.containsConverterType(noSelectionConverter)) {
              converterChain.addConverterToChain(noSelectionConverter, ConverterChain.CHAIN_START);
           }
           return s;
        }
        else
        {
           return null;
        }
     }
  
     @SuppressWarnings("unchecked")
     private void initVar(Object varValue)
     {
        if (getVar() == null)
        {
           throw new FacesException("var attribute must be set");
        }
        getFacesContext().getExternalContext().getRequestMap().put(getVar(), varValue);
     }
  
     private void destroyVar()
     {
        getFacesContext().getExternalContext().getRequestMap().remove(getVar());
     }
  
     private Object getParentValue()
     {
        if (getParent() instanceof ValueHolder)
        {
           ValueHolder parent = (ValueHolder) getParent();
           return parent.getValue();
        }
        else
        {
           return null;
        }
     }
  	
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UITaskId.java
  
  Index: UITaskId.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIParameter;
  import javax.faces.el.ValueBinding;
  
  import org.jbpm.taskmgmt.exe.TaskInstance;
  
  /**
   * JSF component class
   *
   */
  public class UITaskId extends UIParameter {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.TaskId";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.TaskId";
     
     @Override
     public String getFamily()
     {
        return COMPONENT_FAMILY;
     }
  	
     @Override
     public String getName()
     {
        return "taskId";
     }
     
     @Override
     public Object getValue()
     {
        ValueBinding valueBinding = getValueBinding("taskInstance");
        if (valueBinding==null) valueBinding = getFacesContext().getApplication().createValueBinding("#{task}");
        TaskInstance taskInstance = (TaskInstance) valueBinding.getValue( getFacesContext() );
        return taskInstance==null ? null : taskInstance.getId();
     }
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UISeamCommandBase.java
  
  Index: UISeamCommandBase.java
  ===================================================================
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.ActionSource;
  import javax.faces.component.UIComponent;
  import javax.faces.component.UIData;
  import javax.faces.component.UIOutput;
  import javax.faces.el.MethodBinding;
  import javax.faces.event.ActionListener;
  import javax.faces.model.DataModel;
  
  public abstract class UISeamCommandBase extends UIOutput implements ActionSource
  {
     
  public abstract String getDisabled();
     
     public abstract void setDisabled(String disabled);
     
     public boolean disabled() {
       return new Boolean(getDisabled());
     }
     
     public abstract String getView();
     
     public abstract void setView(String view);
     
     public abstract MethodBinding getAction();
     
     public abstract void setAction(MethodBinding action);
     
     public abstract String getOutcome();
     
     public abstract void setOutcome(String outcome);
     
     public abstract String getPropagation();
     
     public abstract void setPropagation(String propagtion);
     
     public abstract String getPageflow();
     
     public abstract void setPageflow(String pageflow);
     
     public abstract String getFragment();
     
     public abstract void setFragment(String fragment);
     
     public abstract String getOnclick();
     
     public abstract void setOnclick(String onclick);
  
     public UISelection getSelection()
     {
        UIData parentUIData = getParentUIData();
        if (parentUIData!=null)
        {
           if ( parentUIData.getValue() instanceof DataModel )
           {
              String dataModelExpression = parentUIData.getValueBinding("value").getExpressionString();
              String dataModelName = dataModelExpression.substring(2, dataModelExpression.length()-1).replace('$','.');
              UISelection uiSelection = new UISelection();
              uiSelection.setDataModel(dataModelName);
              uiSelection.setVar( parentUIData.getVar() );
              return uiSelection;
           }
           else
           {
              return null;
           }
        }
        else
        {
           return null;
        }
     }
     
     public UIData getParentUIData()
     {
        UIComponent parent = this.getParent();
        while (parent!=null)
        {
           if (parent instanceof UIData)
           {
              return (UIData) parent;
           }
           else 
           {
              parent = parent.getParent();
           }
        }
        return null;
     }
     
     public void addActionListener(ActionListener listener)
     {
        // TODO Auto-generated method stub  
     }
     
     public void removeActionListener(ActionListener listener)
     {
        // TODO Auto-generated method stub
     }
     
     public ActionListener[] getActionListeners()
     {
        // TODO Auto-generated method stub
        return null;
     }
  
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIDiv.java
  
  Index: UIDiv.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIComponentBase;
  
  /**
   * JSF component class
   *
   */
  public abstract class UIDiv extends UIComponentBase {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Div";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Div";
  	
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIConversationIsLongRunning.java
  
  Index: UIConversationIsLongRunning.java
  ===================================================================
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIParameter;
  
  import org.jboss.seam.core.Manager;
  
  /*
   * This component not available as a tag
   */
  public class UIConversationIsLongRunning extends UIParameter
  {
     
     public static final String COMPONENT_FAMILY = "org.jboss.seam.ui.ConversationIsLongRunning";
     
     @Override
     public String getFamily()
     {
        return COMPONENT_FAMILY;
     }
     
     @Override
     public String getName()
     {
        return Manager.instance().getConversationIsLongRunningParameter();
     }
     
     @Override
     public Object getValue()
     {
        return Manager.instance().isReallyLongRunningConversation();
     }
  
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIFileUpload.java
  
  Index: UIFileUpload.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIComponentBase;
  import javax.faces.el.ValueBinding;
  
  /**
   * JSF component class
   *
   */
  public abstract class UIFileUpload extends UIComponentBase {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.FileUpload";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.FileUpload";
     
     public abstract String getAccept();
     
     public abstract void setAccept(String accept);
     
     public abstract String getStyleClass();
     
     public abstract void setStyleClass(String styleClass);
     
     public abstract void setStyle(String style);
     
     public abstract String getStyle();
     
     public abstract ValueBinding getData();
     
     public abstract void setData(ValueBinding data);
  
     public abstract ValueBinding getContentType();
     
     public abstract void setContentType(ValueBinding contentType);
     
     public abstract ValueBinding getFileName();
     
     public abstract void setFileName(ValueBinding fileName);
     
     public abstract ValueBinding getFileSize();
     
     public abstract void setFileSize(ValueBinding fileSize); 
     
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIButton.java
  
  Index: UIButton.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIComponent;
  import javax.faces.component.UIData;
  import javax.faces.el.MethodBinding;
  import javax.faces.event.ActionListener;
  import javax.faces.model.DataModel;
  
  /**
   * JSF component class
   *
   */
  public abstract class UIButton extends UISeamCommandBase  {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Button";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Button";
     
     public abstract String getImage();
     
     public abstract void setImage(String image);
     
     
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UICache.java
  
  Index: UICache.java
  ===================================================================
  /**
   * License Agreement.
   * 
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   * 
   * Copyright (C) 2007 Exadel, Inc.
   * 
   * This library is free software; you can redistribute it and/or modify it under
   * the terms of the GNU Lesser General Public License version 2.1 as published
   * by the Free Software Foundation.
   * 
   * This library is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
   * details.
   * 
   * You should have received a copy of the GNU Lesser General Public License
   * along with this library; if not, write to the Free Software Foundation, Inc.,
   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIComponentBase;
  
  
  /**
   * JSF component class
   * 
   */
  public abstract class UICache extends UIComponentBase
  {
  
     private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Cache";
  
     private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Cache";
     
     @Override
     public String getFamily()
     {
        return COMPONENT_FAMILY;
     }
     
     public abstract Boolean getEnabled();
     
     public abstract void setEnabled(Boolean enabled);
     
     public abstract String getKey();
     
     public abstract void setKey(String key);
     
     public abstract String getRegion();
     
     public abstract void setRegion(String region);
  
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIConversationId.java
  
  Index: UIConversationId.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIParameter;
  
  import org.jboss.seam.core.Conversation;
  import org.jboss.seam.core.Manager;
  import org.jboss.seam.core.Pages;
  import org.jboss.seam.pages.Page;
  
  /**
   * JSF component class
   *
   */
  public class UIConversationId extends UIParameter {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.ConversationId";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.ConversationId";
  	
     private String viewId;
     
  	@Override
  	public String getFamily()
  	{
  	   return COMPONENT_FAMILY;
  	}
     
     
     @Override
     public String getName()
     {
        Conversation conversation = Conversation.instance();
        if (viewId!=null && ( !conversation.isNested() || conversation.isLongRunning() ) )
        {
           return Pages.instance().getPage(viewId)
                       .getConversationIdParameter()
                       .getParameterName();
        }
        else
        {
           return Manager.instance().getConversationIdParameter();
        }
     }
     
     @Override
     public Object getValue()
     {
        Conversation conversation = Conversation.instance();
        if ( !conversation.isNested() || conversation.isLongRunning() )
        {
           if (viewId!=null)
           {
              Page page = Pages.instance().getPage(viewId);
              return page.getConversationIdParameter().getParameterValue();
           }
           else
           {
              return conversation.getId();
           }
        }
        else
        {
           return conversation.getParentId();
        }
     }
  
     public String getViewId()
     {
        return viewId;
     }
  
     public void setViewId(String viewId)
     {
        this.viewId = viewId;
     }
     
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UILink.java
  
  Index: UILink.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  
  /**
   * JSF component class
   *
   */
  public abstract class UILink extends UISeamCommandBase {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Link";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Link";
  	
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIValidateAll.java
  
  Index: UIValidateAll.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import java.util.List;
  
  import javax.faces.component.EditableValueHolder;
  import javax.faces.component.UIComponent;
  import javax.faces.component.UIComponentBase;
  
  import org.jboss.seam.ui.validator.ModelValidator;
  
  
  
  /**
   * JSF component class
   *
   */
  public abstract class UIValidateAll extends UIComponentBase {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.ValidateAll";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.ValidateAll";
  	
     @Override
     public String getFamily()
     {
        return COMPONENT_FAMILY;
     }
     
     @Override
     public List getChildren()
     {
        addValidators( super.getChildren() );
        return super.getChildren();
     }
  
     private void addValidators(List children)
     {
        for (Object child: children)
        {
           if (child instanceof EditableValueHolder)
           {
              EditableValueHolder evh =  (EditableValueHolder) child;
              if ( evh.getValidators().length==0 && evh.getValidator()==null )
              {
                 evh.addValidator( new ModelValidator() );
              }
           }
           else if (child instanceof UIComponent)
           {
              addValidators( ( (UIComponent) child ).getChildren() );
           }
        }
     }
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIMessage.java
  
  Index: UIMessage.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIComponent;
  import javax.faces.component.html.HtmlMessage;
  
  /**
   * JSF component class
   *
   */
  public abstract class UIMessage extends HtmlMessage {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Message";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Message";
  
      private String getFor(UIComponent component)
        {
           /*if (component instanceof UIDecorate) 
           {
              return Decorate.getInputId(component);
           }
           else if ( component.getParent() instanceof UIDecorateAll )
           {
              return Decorate.getInputId(component);
           }
           else if ( component.getParent()==null )
           {
              return null;
           }
           else
           {*/
              return getFor( component.getParent() );
           /*}*/
        }
  
        @Override
        public String getFor()
        {
           return getFor(this);
        }
     
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIAction.java
  
  Index: UIAction.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIParameter;
  import javax.faces.context.FacesContext;
  
  import org.jboss.seam.core.Pages;
  import org.jboss.seam.core.SafeActions;
  
  /*
   * This is a support component and is not processed by the CDK (doesn't appear in faces-config)
   *
   */
  public class UIAction extends UIParameter {
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Action";
     
     @Override
     public String getFamily()
     {
       return COMPONENT_FAMILY;
     }
     
     private String action;
     
     public String getAction() 
     {
        return action;
     }
     
     public void setAction(String action)
     {
        this.action = action;
     }
     
     private boolean isMethodBinding()
     {
        return getAction().startsWith("#{");
     }
  
     @Override
     public String getName()
     {
        return isMethodBinding() ? "actionMethod" : "actionOutcome";
     }
     
     @Override
     public Object getValue()
     {
        String viewId = Pages.getCurrentViewId();
        if ( isMethodBinding() )
        {
           String actionId = SafeActions.toActionId( viewId, getAction() );
           SafeActions.instance().addSafeAction(actionId);
           return actionId;
        }
        else
        {
           return getAction();
        }
     }
     
     @Override
     public void restoreState(FacesContext context, Object state) {
        Object[] values = (Object[]) state;
        super.restoreState(context, values[0]);
        action = (String) values[1];
     }
  
     @Override
     public Object saveState(FacesContext context) {
        Object[] values = new Object[2];
        values[0] = super.saveState(context);
        values[1] = action;
        return values;
     }
  	
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UISpan.java
  
  Index: UISpan.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIComponentBase;
  
  /**
   * JSF component class
   *
   */
  public abstract class UISpan extends UIComponentBase {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Span";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Span";
  	
  }
  
  
  
  1.1      date: 2007/03/20 17:58:58;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UISelection.java
  
  Index: UISelection.java
  ===================================================================
  /**
   * License Agreement.
   *
   * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
   *
   * Copyright (C) 2007 Exadel, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License version 2.1 as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   */
  
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.UIParameter;
  import javax.faces.context.FacesContext;
  import javax.faces.model.DataModel;
  
  import org.jboss.seam.contexts.Contexts;
  
  /**
   * JSF component class
   *
   */
  public class UISelection extends UIParameter {
  	
  	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Selection";
  	
  	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Selection";
     
     @Override
     public String getFamily()
     {
        return COMPONENT_FAMILY;
     }
     
     @Override
     public String getName()
     {
        return "dataModelSelection";
     }
     
     @Override
     public Object getValue()
     {
        Object value = Contexts.lookupInStatefulContexts(dataModel);
        if (value==null)
        {
           return null;
        }
        else
        {
           int rowIndex = ( (DataModel) value ).getRowIndex();
           return rowIndex<0 ? null : var + ':' + dataModel + '[' + rowIndex + ']';
        }
     }
     
     /* Variables */
     
     private String dataModel;
     private String var;
     
     @Override
     public void restoreState(FacesContext context, Object state) {
        Object[] values = (Object[]) state;
        super.restoreState(context, values[0]);
        dataModel = (String) values[1];
     }
  
     @Override
     public Object saveState(FacesContext context) {
        Object[] values = new Object[2];
        values[0] = super.saveState(context);
        values[1] = dataModel;
        return values;
     }
  
     public String getDataModel()
     {
        return dataModel;
     }
  
     public void setDataModel(String dataModel)
     {
        this.dataModel = dataModel;
     }
  
     public String getVar()
     {
        return var;
     }
  
     public void setVar(String var)
     {
        this.var = var;
     }
  	
  }
  
  
  



More information about the jboss-cvs-commits mailing list