Re: DynaActionForm questions
The Bean en PropertyUtils should also be completely working with dynbean interface. for example PropertyUtils.copyProperties(object,object) doesn't work right now I see that they want to do something with PropertyDescriptors? I think that is a dead end. Because property descripters are completely different they are really for get and set methods. johan - Original Message - From: Niall Pemberton [EMAIL PROTECTED] To: Struts Developers List [EMAIL PROTECTED] Sent: Sunday, March 17, 2002 4:37 AM Subject: RE: DynaActionForm questions I haven't looked at DynaActionForm yet, but we are just starting to use DynaBeans - isn't the beauty of all this stuff that you don't have to use the provided DynaActionForm, but just go create your own version that suits your needs - sub-class ActionForm, implement the DynaBean interface and Bob's your uncle, it'll all work for you too - if its good and you think others would use it, submit it back to struts - I'm sure theres room for more than one implementation. Niall -Original Message- From: Bryan Field-Elliot [mailto:[EMAIL PROTECTED]] Sent: 15 March 2002 21:26 To: Struts Developers List Subject: Re: DynaActionForm questions Thanks Craig, On Fri, 2002-03-15 at 14:19, Craig R. McClanahan wrote: Pretty slick, huh? :-) It is slick indeed. The intended focus could just use a little more refining (perhaps in the users manual). If you know what your app needs to ask for, then DynaActionForms are a new and easier way to express it. On the other hand, if your application doesn't know what it's going to be asking for until runtime, then DynaActionForms aren't the complete solution, although they will probably be part of the solution I ultimately build. The two scenarios are pretty different, and the use of the dyna keyword could lead over-eager developers like me to assume something that isn't there. Thanks, Bryan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Nested properties everywhere....
I know i can do 2 define to get the maxRows and startCounter i do it now because there is not other way but it clutters the view and is a bit annoying to constantly define things. Nested everywhere for every tag where you can define a bean would be so much nicer and the jsp code would be much cleaner to read.. And it is a small modification for BeanUtils (or PropertyUtils) The only thing it needs to do is first check if there is a nested delimiter if so then try to find the first in the specific scope (if any) then do it the current way. johan - Original Message - From: Arron Bates [EMAIL PROTECTED] To: Struts Developers List [EMAIL PROTECTED] Sent: Thursday, February 21, 2002 1:19 PM Subject: Re: Nested properties everywhere The tags use direct values or beans themselves to provide values for offsets and such. Would be quite a bit of work to get them all to work off bean properties instead, and there's the added decision of telling the tag that it is to use the values of properties rather than bean refs and values. The nested tags are the same in this regard, as the rely on the original tag to do its thang. When the original tags get the ability, the nested tags will get the ability, but of course they'll add the ability to have the property relative to the current nested bean level. You can get around it though, by using the bean define, working on a property to get a value into a bean reference, then use the bean name for the offsets and such. And of course, when using the nested tags, the bean define will be nested, so it's not like it can't be done. The define tag can also put beans into whatever scope which is one of the things that you're after. Arron. Johan Compagner wrote: Hi, I really would like to see that i can type nested properties everywhere. so every parameter of a tag that can map to a bean in the whatever scope should be able to use nested tags.. So to give an example: logic:iterate id=obj name=listbean.list scope=request offset=listbean.startCounter length=listbean.maxRows ofcouse i could also do this in the above example but it is just a case what should be possible. logic:iterate id=obj name=listbean property=list scope=request offset=listbean.startCounter length=listbean.maxRows This really cleans up the jsp code and is very readable. Or can i use the new nested tags feature for this?? But this does not work: nested:root name=listbean nested:iterate id=obj property=list scope=request offset=startCounter length=maxRows but that doesn't seem to work. johan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Reloadable Class
In fact, even if you use the Admin or Manager tool to reload a webapp, *only* classes loaded from WEB-INF/lib or WEB-INF/classes are reloaded. This is due to limitations of the JDK, not any desires on the part of the Tomcat development team. in jdk1.4 there is hotswap so you can change the class on the fly Great for IDE's and debugging but i also think webapps could use it also. johan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
OptionsTag and SelectTag proposed changes
Hi, I wanted to fill in a Select with Options that are filled out of a Collection. where i could specify a value and label property of the objects that are in that connection. Then i saw that this was already implemented bug only for Collection that are in the request. But that was not the case at my place. Because the collection did came from the Form (where else??) So in the OptionsTag.doEndTag() there is this line: Iterator collIterator = getIterator(collection, null); And that getIterator does this with that name (collection string) Object bean = pageContext.findAttribute(beanName); So it wants the collection in the page/request/session scope directy. But that is not what i want it want this: collIterator = getIterator(name, collection); Where the name is null (then the Constants.BEAN_KEY is used which is the form) or what every i want So i changed it so that the current behaviour is excactly the same because it does if first as it was now But if it can't find it it tries it my way. I replaced the Iterator collIterator = getIterator(collection, null); line with these onces: Iterator collIterator = null; Object colBean = pageContext.findAttribute(collection); if (colBean == null) { collIterator = getIterator(name, collection); } else { collIterator = getIterator(collection, null); } Now another problem arised. How do i get the right onces selected if i use a Collection? Because how does the current selecttag know which where it must get the the right selected values with which it should compare it with the value of the options (that is get from the collection) Because the current behaviour is this: That i calls the BeanUtils.getArrayProperty() for that and does a normal toString on that object if it is not a collection and a toString of the values inside t he collection or array if it is such a thing. But this is not what i want because it could just be an object (directly or inside a collection if multi select) where it must call getPrimaryKey() to get the right value for example. (could be the same valueProperty that the OptionsTag uses) For now this doesn't have to be completely generic. I thought what must i change if i just extend the SelectTag of struts it self. Then i only want to change the matching values. At this time those are generated inside the doStartTag() so i must implement that complete doStartTag() This is not very handy. Can the SelectTag be refactored so that the code for generating the match values is in there own public/protected method so that i can only replace that one with my own? Then the generation of the HMTL select is always the same. i added a generateMatched() method in the SelectTag and where i put the code that is between the else: if (value != null) { match = new String[1]; match[0] = value; } else { // ALL THIS CODE IS in this method: generateMatched(); } Can these 2 be added? It doesn't change any current behaviour as far as i can see, so it shouldn't be to hard. I attached my code with the changes. Johan Compagner SelectTag.java OptionsTag.java
RE: PropertyUtils Enhancement Source Code
1) Created a DynamicProperties interface which has the following methods: public String getValue(String property); public String getValue(int index, String property); public void setValue(String property, String value); public void setValue(int index, String property, String value); Almost the samething i have now. I only have some more (and i don't have at this time the index because i don't believe that is nessesary, because BeanUtils / PropertyUtils are taking care of that! This is My interface that i use for quite sometime know. public interface Property { public java.util.Map getBeanProperties(); // Is needed for the new describe method in PropertyUtils!! public Object getBeanProperty(String sPropertyName); public Class[] getParameterTypes(String sName); // You should be able to get the types of the property. public void setBeanProperty(String sPropertyName, Object oPropertyValue); } 2) Sub-classed ActionServlet and changed the processPopulate method to populate the ActionForm using the above setters if its an instance of DynamicProperties or using its normal reflection if not. No! ActionServlet doesn't have to change at all!! Everychange must only be done in the PropertyUtils and BeanUtils. What does ActionServlet to do with beans? Nothing. Struts only uses the Bean And property utils for filling the beans. At this time only with reflection but i changed Bean And PropertyUtils so that it looks for the above Interface Property and then calls the get or set of that Property Interface. Here some code i changed in the PropertyUtils class: public static void setSimpleProperty(Object bean, String name, Object value) { // If it is of Property if (bean instanceof Property) { // Use that one instead of Reflection (you create youre own reflection interface) ((Property) bean).setBeanProperty(name, value); } else { // Retrieve the property setter method for the specified property PropertyDescriptor descriptor = getPropertyDescriptor(bean, name); if (descriptor == null) throw new NoSuchMethodException(Unknown property ' + name + '); Method writeMethod = getWriteMethod(descriptor); if (writeMethod == null) throw new NoSuchMethodException(Property ' + name + ' has no setter method); // Call the property setter method Object values[] = new Object[1]; values[0] = value; writeMethod.invoke(bean, values); } } 3) Modified Struts tags to retrieve bean values using the above getters if its an instance of DynamicProperties or using its normal reflection if not. No tag doesn't have to be changed in my way. Because all is done throught the Property and BeanUtils classes!!! 4) Created a sub-class of ActionForm (DynamicActionForm) which implements our DynamicProperties interface. No this can be done by the programmers themself just do this: public class DynamicForm extends ActionForm implements org.apache.struts.util.Property And then they must implement the four methods. Ofcourse Struts could create a default DynamicForm that uses a Hashmap for storing its properties only the getParameterTypes would be a bit difficut then! (i will think this over) Now we only have one DynamicActionForm and don't have to go round setting up loads of different ActionForm classes. The DynamicActionForm is a bit simplistic and wouldn't suit everyones needs, but the advantage of this is people could create their own concrete implementations. If they just uses my interface then it is very easy to do this. It would be interesting to hear others opinions on how dynamic properties should be implemented. given :-) Niall Johan Compagner P.S. I am willing to give my implementation of the Property interface and the changes to BeanUtils/PropertyUtils email me if you want.
Re: Bean philosophy
Dynamic properties are a very very very heavily requested feature, and will undoubtedly be addressed early in the Struts 1.1 development cycle. Supporting them elegantly is more than just a couple of tweaks here and there, so we want to make sure that we've got all the bases covered with our design. hmmm. It is working here for quite sometime now and i just inserted one Interface and i tweaked 2 classes: BeanUtils and PropertyUtils. So i really think the basic is a couple of tweaks. After that maybe other people say but also this Johan
Re: cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
I looked into that when doing the patch. Because these calls are all protected by hasNext() checks, IMHO you are guaranteed that there really will be a next element. Therefore, the only way you can get a null back is if your collection itself contains a null element. This is legal in the general case of Java development, but it's hard to say what a null value should mean in the context of an html:options tag. What do you think the behavior should be in that case? As i said before. I always have the Collection filled in but.. One thing should it not do: a null string in the html if it finds a null it should do insert an empty in the html. johan
Re: IF / ELSE and SWITCH/CASE Tags
Great idee's!! First thing to be included after the final of 1.0?? johan - Original Message - From: Niall Pemberton [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 15, 2001 8:15 AM Subject: IF / ELSE and SWITCH/CASE Tags Can I submit these logic tags for inclusion in Struts - they are on the TODO list for 1.1? Attached are tags to do If/Else and Switch/Case logic, based on existing Struts logic tag classes - the key classes inherit from the Struts CompareTagBase. 1) IF/ELSE: (IfTag, ThenTag, ElseTag) The IfTag provides the same functionality as the Equal, NotEqual, LessEqual, LessThan, GreaterThan, GreaterEqual, Match, NoMatch, Present, NotPresent tags by specifying that in the op attribute. Example Usage: logic:if op=GreaterThan name=testbean property=doubleProperty value=400 logic:then Property Greater Than Value /logic:then logic:else Property Not Greater Than Value /logic:else /logic:if 2) SWITCH/CASE: (SwitchTag, CaseTag, DefaultTag) Example Usage: logic:switch name=testbean property=doubleProperty logic:case value =11 matched/logic:case logic:case value =321321 matched 1st/logic:case logic:case value =321321 matched 2nd/logic:case logic:case value =55 matched/logic:case logic:defaultNo values matched - default processing/logic:default /logic:switch [[ LOGIC.ZIP : 1568 in winmail.dat ]]
BeanMessage Tag proposal
Hi, When setting the args (arg0,arg1,arg2,arg3,arg4) you must do this: bean:message key="foo.foo.foo" arg0="foo1" arg1="foo2"/ But i think it is very rare that you know exactly at design time of the jsp what value there must be. Because if you do then why not set it directly in the message it self? So it is almost any time a runtime expression. But then i must do things like this: bean:define id="argstring1" value="totalautotheft"/ bean:define id="argstring2" value="autotheft"/ bean:define id="insurance" name="carinsurance" scope="session" type="nl.topicus.thema.DynamicForm"/ bean:message key="prompt.advise.wacasco" arg0="%= insurance.getProperty(argstring1).toString() %" arg1="%= insurance.getProperty(argstring2).toString() %"/ I must define bean:define id="argstring1" value="totalautotheft"/ because i can't do this: bean:message arg0="%= insurance.getProperty("totalautotheft").toString() %" I find this a bug of the Tomcat parser if you ask me. Because if he sees that it is a reqexpr (%=) then it should first find the % before looking at the closing "!! Because if these problems i wanted to find a solution Why is is not possible that i get the Object[] from a name/property??? Then the BeanTag is also not limmited to only 5 args My example for the above one: app:message key="prompt.advise.wacasco" (arg)name="insurance" (arg)property="wacascoObjects"/ and the insurance.getWacascoObjects() does return the Object[] for that string: object[0] = insurance.getProperty("totalautotheft"); object[1] = insurance.getProperty("autotheft"); return object; Johan Compagner
Database pooling comments (org.apache.struts.sql)
s the same Connection, because it is in same transaction/thread // This is absolutly necessary because i would run out of connections when i don't get the same connection back // If for example only 2 connections can be made (the max value) and the Country also did a call to // another object which also called datasource.getConnection() there would be a deadlock // In the current implementation of struts/my program i give the current connection with the method call Connection connection = datasource.getConnection(); // Select the country Return country. } } Anybody interrested or has more idee's about this? 5 About the pooling framework: In the GenericXXXPool classes objects are being destroyed if they are are idle long enough. This is in a loop that is completly synchronized so when it runs and walks through the complete list the pool is completely locked I really would like to have an implementation that uses weak references. So a cache object pool. Let the JVM decide when there is not enough memory anymore. This wouldn't work for everything because you lose the abillty to call destroy (or you must do this in the finalize of the wrapper around the real object) Johan Compagner
Re: Support for submitting unchecked checkboxes
Yes but how do you set that hidden field if the checkbox value changes? You must also use javascript then i believe johan - Original Message - From: "Howard Moore" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 22, 2001 11:04 AM Subject: RE: Support for submitting unchecked checkboxes One problem with this is that it fails if javascript is disabled on the client. An alternative hack would be to have a hidden field and the checkbox both with the same name and have Struts process them as a special case when populating the ActionForm. -Original Message- From: Johan Compagner [mailto:[EMAIL PROTECTED]] Sent: 22 February 2001 09:03 To: [EMAIL PROTECTED] Subject: Re: Support for submitting unchecked checkboxes +1 Please insert this (or something like this) in the 1.0 code base, because checkboxes are useless at this time to use!! johan - Original Message - From: "Laine Donlan" [EMAIL PROTECTED] To: "Struts Dev (E-mail)" [EMAIL PROTECTED] Sent: Tuesday, February 20, 2001 2:19 PM Subject: Support for submitting unchecked checkboxes In order to capture the act of a user unchecking checkboxes and to initialize the checkbox as checked/unchecked with non boolean values I made a couple of changes to the org.apache.struts.taglib.html.CheckboxTag. Basically the changes consisted of: 1) Using the supplied value attribute to match against the bean property value and generating the 'checked' attribute accordingly. If the value is not supplied then the previously implemented method of checking 'on', 'true', or 'yes' is performed. So I do not think that default behavior should be affected. 2) Added support for two new attributes - submitUnchecked (boolean) and uncheckedValue (String). Neither of these attributes are required and the submitUnchecked defaults to 'false'. If a user chooses to submit unchecked values then two form inputs will be generated that facilitate this function. See below for an example: Tag notation - html:checkbox name="bean" property="indexedBean.property" submitUnchecked="true" uncheckedValue="0" value="1"/ Generated HTML - input type="checkbox" name="indexedBean.property_checkBox" value="1" onclick="(this.checked?this.form['indexedBean.property'].value ='1':this. form['indexedBean.property'].value='0')" input type="hidden" name="indexedBean.property" value="0"/ (where 0 is the current value of the bean property) So in this scenario the actual checkbox param in the request will be ignored and the hidden input will be used to maintain the bean property that the user wishes. In the case where the user does not provide the two new attributes the html will be generated as it is today with the exception of the determination of the checked or unchecked mentioned above. I could not see how this functionality was present in the current checkbox tag without explicitly declaring two tags and adding javascript to the checkbox tag. Even then some scripting may be required to differentiate between the two inputs and to initialize the hidden one. If I missed something could someone point me in the right direction. I have attached the CheckboxTag.java file for review and use if anyone is interested. CheckboxTag.zip Thanks. Comments would be appreciated. Laine
Re: [VOTE] Struts 1.0-beta-1 Release Plan
+1 - Original Message - From: "Craig R. McClanahan" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 20, 2001 7:18 AM Subject: [VOTE] Struts 1.0-beta-1 Release Plan Now that the TODO list for 1.0 (and the bug reports in Bugzilla) are dwindling away, it's time for a 1.0-beta-1 release of Struts! I just checked in an initial draft of a release plan that talks about what will happen, and the criteria for release. Please take a moment to review this document: http://jakarta.apache.org/struts/release-plan-1.0b1.html and vote on your acceptance of this plan. Release plans must pass by a majority vote of committers on the project, but all other interested parties are welcome to cast their votes (and/or make comments or suggestions on the plan) as well. Craig McClanahan
GenericConnection.close() - Test before setting before resetting to default.
Hi, I use the JDBCODBC driver at this time to a Access DB (just in the development fase) And i have build in a PreparedStatement Connection pool. So that connection.preparedStatement returns a pooled one instead of creating new ones all the time. in the Close() of my GenericPreparedStatement class i return it to the pool of the GenericConnection. But when the GenericConnection is closed. the close() method of GenericConnection just set's the default values like this: (and for readonly, ect ect) try { conn.setCatalog(this.catalog); } catch (SQLException e) { ; } The problem is that when i set the Catalog even it is not changed i can't use my PreparedStatements anymore, the next time i use one after thet setCatalog call i get a exception: Function Sequence Error So what i did for all the default params is first test it if it is changed: try { if(!conn.getCatalog().equals(this.catalog)) { conn.setCatalog(this.catalog); } } catch (SQLException e) { ; } Can struts do the same? Why resetting a default property if it isn't changed? I attached my GenericConnection and all the classes that are added and changed for the preparedStatement Pool. Maybe this is something for struts? By Default nothing is cached or pooled because the CacheStatements boolean of the GenericDataSource i added is false. It would be nice if i could set that property in the struts-config.xml file in the datasource section. Johan GenericPreparedStatement.java GenericDataSource.java GenericConnection.java
OptionsTag comments
Hi, I want to set the value of a Option. That value is a integer. So first i thougth i can just return a int[] But then i get a class cast exception because the OptionsTag.getIterater(String,String) does check if it is a array and then cast it to a Object[] which it isn't. (Maybe this should be in the doc!) if (collection.getClass().isArray()) collection = Arrays.asList((Object[]) collection); But then i thought, OK then i make it Integer object array. But then the OptionsTag.doEndTag() throws a class cast exception because all the values that are in the iterator are cast to a string! while (valuesIterator.hasNext()) { String value = (String) valuesIterator.next(); ^^ String label = value; if (labelsIterator.hasNext()) label = (String) labelsIterator.next(); addOption(sb, value, label, match); } The first thing (it can't be a primitive array, i can live with) But why must it be a string? Just do this: String value = valuesIterator.next().toString(); If you want it to be a String. This is because the selected value is also just a int in the Form class. So why must i myself make it a string? Johan
ActionServlet.reload()
If i changed the Struts-config.xml file and i changed the datasources. Then the reload of the ActionServlet doesn't close the current datasources and start them up again. I know this is a bit difficult because what to do when a connection of a datasource is currently in use?? I came across this because i overloaded the init function of the ActionServlet where i create some Application scope objects which are used throughout the complete application. Those objects have some dependencies to each other. And those are set in the init(). But after a reload the DatabaseMessageResources doesn't have the link to the database class anymore because that i do in the init() Can't all the things (including datasources) be closed in the reload() and then just call the init() method from the reload() so that it looks that the servlet get's loaded again? Johan Compagner