⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rendererutils.java

📁 一个使用struts+hibernate+spring开发的完的网站源代码。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                            ValueBinding binding = items.getValueBinding("value");                            throw new IllegalArgumentException("Collection referenced by UISelectItems with binding '"+                                    binding.getExpressionString()+"' and Component-Path : " + getPathToComponent(child) + " does not contain Objects of type SelectItem");                        }                        list.add(item);                    }                }                else if (value instanceof Map)                {                    for (Iterator it = ((Map)value).entrySet().iterator(); it.hasNext();)                    {                        Map.Entry entry = (Map.Entry)it.next();                        list.add(new SelectItem(entry.getValue(), entry.getKey().toString()));                    }                }                else                {                    ValueBinding binding = items.getValueBinding("value");                    throw new IllegalArgumentException("Value binding '"+                            (binding==null?null:binding.getExpressionString())+"'of UISelectItems with component-path " + getPathToComponent(child) + " does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : "+((value==null)?null:value.getClass().getName()));                }            }            else            {                //todo: may other objects than selectItems be nested or not?                //log.error("Invalid component : " + getPathToComponent(child) + " : must be UISelectItem or UISelectItems, is of type : "+((child==null)?"null":child.getClass().getName()));            }        }        return list;    }    /**     * Convenient utility method that returns the currently submitted values of     * a UISelectMany component as a Set, of which the contains method can then be     * easily used to determine if a select item is currently selected.     * Calling the contains method of this Set with the renderable (String converted) item value     * as argument returns true if this item is selected.     * @param uiSelectMany     * @return Set containing all currently selected values     */    public static Set getSubmittedValuesAsSet(FacesContext context, UIComponent component, Converter converter, UISelectMany uiSelectMany)    {        Object submittedValues = uiSelectMany.getSubmittedValue();        if (submittedValues == null)        {            return null;        }        return internalSubmittedOrSelectedValuesAsSet(context, component, converter, uiSelectMany, submittedValues);    }    /**     * Convenient utility method that returns the currently selected values of     * a UISelectMany component as a Set, of which the contains method can then be     * easily used to determine if a value is currently selected.     * Calling the contains method of this Set with the item value     * as argument returns true if this item is selected.     * @param uiSelectMany     * @return Set containing all currently selected values     */    public static Set getSelectedValuesAsSet(FacesContext context, UIComponent component, Converter converter, UISelectMany uiSelectMany)    {        Object selectedValues = uiSelectMany.getValue();        return internalSubmittedOrSelectedValuesAsSet(context, component, converter, uiSelectMany, selectedValues);    }            /**     * Convenient utility method that returns the currently given value as String,     * using the given converter.     * Especially usefull for dealing with primitive types.     */    public static String getConvertedStringValue(FacesContext context,            UIComponent component, Converter converter, Object value) {        if (converter == null) {            if (value == null) {                return "";            } else if (value instanceof String) {                return (String) value;            } else {                throw new IllegalArgumentException(                        "Value is no String and component "                                + component.getClientId(context)                                + " does not have a Converter");            }        }        return converter.getAsString(context, component, value);    }            /**     * Convenient utility method that returns the currently given SelectItem value     * as String, using the given converter.     * Especially usefull for dealing with primitive types.     */    public static String getConvertedStringValue(FacesContext context,            UIComponent component, Converter converter, SelectItem selectItem) {        return getConvertedStringValue(context, component, converter, selectItem.getValue());    }        private static Set internalSubmittedOrSelectedValuesAsSet(FacesContext context,            UIComponent component, Converter converter, UISelectMany uiSelectMany,            Object values)    {        if (values == null || values == EMPTY_STRING)        {            return Collections.EMPTY_SET;        }        else if (values instanceof Object[])        {            //Object array            Object[] ar = (Object[])values;            if (ar.length == 0)            {                return Collections.EMPTY_SET;            }            HashSet set = new HashSet(HashMapUtils.calcCapacity(ar.length));            for (int i = 0; i < ar.length; i++)            {                set.add( getConvertedStringValue(context, component, converter, ar[i]) );            }            return set;        }        else if (values.getClass().isArray())        {            //primitive array            int len = Array.getLength(values);            HashSet set = new HashSet(HashMapUtils.calcCapacity(len));            for (int i = 0; i < len; i++)            {                set.add( getConvertedStringValue(context, component, converter, Array.get(values,i)) );            }            return set;        }        else if (values instanceof List)        {            List lst = (List)values;            if (lst.size() == 0)            {                return Collections.EMPTY_SET;            }            else            {                HashSet set = new HashSet(HashMapUtils.calcCapacity(lst.size()));                for(Iterator i =lst.iterator(); i.hasNext(); )                    set.add( getConvertedStringValue(context, component, converter, i.next()) );                                return set;            }        }        else        {            throw new IllegalArgumentException("Value of UISelectMany component with path : " + getPathToComponent(uiSelectMany) + " is not of type Array or List");        }    }    public static Object getConvertedUIOutputValue(FacesContext facesContext,                                                   UIOutput output,                                                   Object submittedValue)        throws ConverterException    {        if (submittedValue!=null && !(submittedValue instanceof String))        {            throw new IllegalArgumentException("Submitted value of type String for component : "+                    getPathToComponent(output)+"expected");        }        Converter converter;        try        {            converter = findUIOutputConverter(facesContext, output);        }        catch (FacesException e)        {            throw new ConverterException(e);        }        if (converter == null)        {            //No conversion needed            return submittedValue;        }        else        {            //Conversion            return converter.getAsObject(facesContext, output, (String)submittedValue);        }    }    public static Object getConvertedUISelectManyValue(FacesContext facesContext,                                                       UISelectMany selectMany,                                                       Object submittedValue)            throws ConverterException    {        if (submittedValue == null)        {            return null;        }        else        {            if (!(submittedValue instanceof String[]))            {                throw new ConverterException("Submitted value of type String[] for component : "                                             + getPathToComponent(selectMany) + "expected");            }        }        return _SharedRendererUtils.getConvertedUISelectManyValue(facesContext,                                                                  selectMany,                                                                  (String[])submittedValue);    }    public static boolean getBooleanAttribute(UIComponent component,                                              String attrName,                                              boolean defaultValue)    {        Boolean b = (Boolean)component.getAttributes().get(attrName);        return b != null ? b.booleanValue() : defaultValue;    }        public static int getIntegerAttribute(UIComponent component,                                          String attrName,                                          int defaultValue)    {        Integer i = (Integer)component.getAttributes().get(attrName);        return i != null ? i.intValue() : defaultValue;    }    public static UIForm findParentForm(UIComponentBase comp)    {        UIComponent parent = comp.getParent();        while (parent != null)        {            if (parent instanceof UIForm)            {                return (UIForm)parent;            }            parent = parent.getParent();        }        return null;    }    public static void copyHtmlInputTextAttributes(HtmlInputText src, HtmlInputText dest)    {        dest.setId(src.getId());        dest.setImmediate(src.isImmediate());        dest.setTransient(src.isTransient());        dest.setAccesskey(src.getAccesskey());        dest.setAlt(src.getAlt());        dest.setConverter(src.getConverter());        dest.setDir(src.getDir());        dest.setDisabled(src.isDisabled());        dest.setLang(src.getLang());        dest.setLocalValueSet(src.isLocalValueSet());        dest.setMaxlength(src.getMaxlength());        dest.setOnblur(src.getOnblur());        dest.setOnchange(src.getOnchange());        dest.setOnclick(src.getOnclick());        dest.setOndblclick(src.getOndblclick());        dest.setOnfocus(src.getOnfocus());        dest.setOnkeydown(src.getOnkeydown());        dest.setOnkeypress(src.getOnkeypress());        dest.setOnkeyup(src.getOnkeyup());        dest.setOnmousedown(src.getOnmousedown());        dest.setOnmousemove(src.getOnmousemove());        dest.setOnmouseout(src.getOnmouseout());        dest.setOnmouseover(src.getOnmouseover());        dest.setOnmouseup(src.getOnmouseup());        dest.setOnselect(src.getOnselect());        dest.setReadonly(src.isReadonly());        dest.setRendered(src.isRendered());        dest.setRequired(src.isRequired());        dest.setSize(src.getSize());        dest.setStyle(src.getStyle());        dest.setStyleClass(src.getStyleClass());        dest.setTabindex(src.getTabindex());        dest.setTitle(src.getTitle());        dest.setValidator(src.getValidator());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -