001    package railo.runtime.tag;
002    
003    import railo.runtime.ComponentPro;
004    import railo.runtime.ComponentScope;
005    import railo.runtime.exp.ApplicationException;
006    import railo.runtime.exp.ExpressionException;
007    import railo.runtime.exp.PageException;
008    import railo.runtime.exp.PageRuntimeException;
009    import railo.runtime.ext.tag.DynamicAttributes;
010    import railo.runtime.ext.tag.TagImpl;
011    import railo.runtime.type.KeyImpl;
012    
013    /**
014    * Defines components as complex types that are used for web services authoring. The attributes of this tag are exposed as component metadata and are subject to inheritance rules.
015    *
016    *
017    *
018    **/
019    public final class Property extends TagImpl  implements DynamicAttributes{
020            
021            private railo.runtime.component.Property property=new railo.runtime.component.Property();
022            
023            /**
024            * @see javax.servlet.jsp.tagext.Tag#release()
025            */
026            public void release()   {
027                    super.release();
028                    
029                    property=new railo.runtime.component.Property();
030            }
031            
032            /**
033             * @see railo.runtime.ext.tag.DynamicAttributes#setDynamicAttribute(java.lang.String, java.lang.String, java.lang.Object)
034             */
035            public void setDynamicAttribute(String uri, String name, Object value) {
036                    property.getDynamicAttributes().setEL(KeyImpl.getInstance(name),value);
037            }
038            public void setMetaData(String name, Object value) {
039                    property.getMeta().setEL(KeyImpl.getInstance(name),value);
040            }
041            
042            /** set the value type
043            *  A string; a property type name; data type.
044            * @param type value to set
045            **/
046            public void setType(String type)        {
047                    property.setType(type);
048                    setDynamicAttribute(null, "type", type);
049            }
050    
051            /** set the value name
052            *  A string; a property name. Must be a static value.
053            * @param name value to set
054            **/
055            public void setName(String name)        {
056                    // Fix for axis 1.4, axis can not handle when first char is upper case
057                    //name=StringUtil.lcFirst(name.toLowerCase());
058                    
059                    property.setName(name);
060                    setDynamicAttribute(null, "name", name);
061            }
062            
063        /**
064         * @param _default The _default to set.
065         */
066        public void setDefault(String _default) {
067                    property.setDefault(_default);
068                    setDynamicAttribute(null, "default", _default);
069                    
070        }
071        /**
072         * @param access The access to set.
073         * @throws ExpressionException 
074         */
075        public void setAccess(String access) throws ExpressionException {
076            setDynamicAttribute(null, "access", access);
077                    property.setAccess(access);
078        }
079        /**
080         * @param displayname The displayname to set.
081         */
082        public void setDisplayname(String displayname) {
083                    property.setDisplayname(displayname);
084                    setDynamicAttribute(null, "displayname", displayname);
085        }
086        /**
087         * @param hint The hint to set.
088         */
089        public void setHint(String hint) {
090                    property.setHint(hint);
091                    setDynamicAttribute(null, "hint", hint);
092        }
093        /**
094         * @param required The required to set.
095         */
096        public void setRequired(boolean required) {
097                    property.setRequired(required);
098                    setDynamicAttribute(null, "required", required?"yes":"no");
099        }
100    
101        public void setSetter(boolean setter) {
102                    property.setSetter(setter);
103                    setDynamicAttribute(null, "setter", setter?"yes":"no");
104        }
105    
106        public void setGetter(boolean setter) {
107                    property.setGetter(setter);
108                    setDynamicAttribute(null, "getter", setter?"yes":"no");
109        }
110        
111        /*public void setBatchsize(double batchsize) {
112            notSupported();
113            int ibs=Caster.toIntValue(batchsize);
114                    property.setBatchsize(ibs);
115                    setDynamicAttribute(null, "batchsize", Caster.toDouble(ibs));
116        }
117    
118            public void setCascade(String cascade) throws ORMException {
119                    notSupported();
120            int cas=HibernateCaster.cascade(cascade);
121                    property.setCascade(cas);
122                    setDynamicAttribute(null, "cascade", cascade);
123        }
124            public void setCatalog(String catalog)  {
125                    notSupported();
126            property.setCatalog(catalog);
127                    setDynamicAttribute(null, "catalog", catalog);
128        }
129            public void setCfc(String cfcPath) throws PageException {
130                    notSupported();
131                    Component cfc = CreateObject.doComponent(pageContext, cfcPath);
132                    property.setCfc(cfc);
133                    setDynamicAttribute(null, "cfc", cfcPath);
134        }
135            
136            public void setCollectiontype(String strCollectionType) throws ORMException  {
137                    strCollectionType=strCollectionType.trim().toLowerCase();
138                    notSupported();
139                    int collectionType=HibernateCaster.collectionType(strCollectionType);
140            property.setCollectionType(collectionType);
141                    setDynamicAttribute(null, "collectiontype", strCollectionType);
142        }
143            public void setConstrained(boolean constrained)  {
144                    notSupported();
145            property.setConstrained(constrained);
146                    setDynamicAttribute(null, "constrained", constrained?"yes":"no");
147        }
148    
149            public void setDatatype(String dataType)  {
150                    notSupported();
151            property.setDataType(dataType);
152                    setDynamicAttribute(null, "datatype", dataType);
153        }
154            public void setDynamicinsert(boolean dynamicInsert)  {
155                    notSupported();
156            property.setDynamicInsert(dynamicInsert);
157                    setDynamicAttribute(null, "dynamicinsert", dynamicInsert?"yes":"no");
158        }
159            public void setDynamicupdate(boolean dynamicUpdate)  {
160                    notSupported();
161            property.setDynamicUpdate(dynamicUpdate);
162                    setDynamicAttribute(null, "dynamicupdate", dynamicUpdate?"yes":"no");
163        }
164            public void setElementcolumn(String elementColumn)  {
165                    notSupported();
166            property.setElementColumn(elementColumn);
167                    setDynamicAttribute(null, "elementcolumn", elementColumn);
168        }
169            public void setElementtype(String elementType)  {
170                    notSupported();
171            property.setElementType(elementType);
172                    setDynamicAttribute(null, "elementtype", elementType);
173        }
174            public void setEntityname(String entityName)  {
175                    notSupported();
176            property.setEntityName(entityName);
177                    setDynamicAttribute(null, "entityname", entityName);
178        }
179            public void setFetchbatchsize(double fetchBatchSize)  {
180                    int ifbs=Caster.toIntValue(fetchBatchSize);
181                    notSupported();
182            property.setFetchBatchSize(ifbs);
183                    setDynamicAttribute(null, "fetchbatchsize", Caster.toString(ifbs));
184        }
185            public void setFieldtype(String fieldType)  {
186                    notSupported();
187            property.setFieldType(fieldType);
188                    setDynamicAttribute(null, "fieldtype", fieldType);
189        }
190            public void setFkcolumn(String fkColumn)  {
191                    notSupported();
192            property.setFkColumn(fkColumn);
193                    setDynamicAttribute(null, "fkcolumn", fkColumn);
194        }
195            public void setFormula(String formula)  {
196                    notSupported();
197            property.setFormula(formula);
198                    setDynamicAttribute(null, "formula", formula);
199        }
200            public void setGenerator(String generator)  {
201                    notSupported();
202            property.setGenerator(generator);
203                    setDynamicAttribute(null, "generator", generator);
204        }
205            public void setGenerator(boolean getter)  {
206                    notSupported();
207            property.setGetter(getter);
208                    setDynamicAttribute(null, "getter", getter?"yes":"no");
209        }*/
210            
211            
212        
213        private void notSupported() {
214                    throw new PageRuntimeException(new ApplicationException("this attribute is not supported yet"));
215                    
216            }
217    
218            /**
219             * @see javax.servlet.jsp.tagext.Tag#doStartTag()
220            */
221            public int doStartTag() throws PageException    {
222                    if(pageContext.variablesScope() instanceof ComponentScope) {
223                            ComponentPro comp = ((ComponentScope)pageContext.variablesScope()).getComponent();
224                            comp.setProperty(property);
225                            property.setOwnerName(comp.getAbsName());
226                    }
227                    
228                    return SKIP_BODY;
229            }
230    
231            /**
232            * @see javax.servlet.jsp.tagext.Tag#doEndTag()
233            */
234            public int doEndTag()   {
235                    return EVAL_PAGE;
236            }
237    }