How to override SimpleMenuItem specify the values
Hi, I wanted to add one more attribute to o.a.s.t.b.MenuItem - mouseOverIcon. In this case, I'd extend SimpleMenuItem and add get/set for mouseOverIcon. This class can be plugged in via classtype attribute of item element in tiles-defs.xml. But how do I specify value for mouseOverIcon in item element in xml file. Since the tiles configutation file has to conform with the DTD this is not possible without extending the DTD. I'd also have to write some digester code for this!. Is there any other better way or am I missing something here ? With Regards, R Balaji
Bug in - Dynamic Javascript Dumping ?
Hi, I am using validator for validating the user input in my application. I too defined lot of rules for the same for different pages in the validator-rules.xml. I found the javascript for all the depends (rules), has been dumped in to all the pages, irrespective of , whether that rule is used in this page or not. Assume i have 10 rules defined in my validator-rules.xml and i am using only 5 for this form, i expect that only 5 of them being dumped in to the page. But it is dumping all of the 10. Which make the page size bulky and increases the download time. Does anybody face this kind of issue? .. help me With Regards, R Balaji
Re: Need Help : DispatchAction and html:image without javascript.
Shashank , I really need the ImageButtonDispatchAction, as i am also facing the same problem now. could you please help me , from where can i get the code. With Regards, R Balaji Shashank Dixit wrote: Hello Martin Thanks for your help, I found out the code for ImageButtonDispatchAction and it would be useful for me. Regards, Shashank S. Dixit Associate Software Consultant. Datamatics Ltd. SDF-1, SEEPZ, Andheri,Mumbai - Original Message - From: Martin Naskovski To: Shashank Dixit Cc: Struts Users Mailing List Sent: Thursday, July 24, 2003 12:51 PM Subject: Re: Need Help : DispatchAction and html:image without javascript. Shashank, look for ImageButtonDispatchAction.java in the archives of 'struts-user'. The image buttons get submitted as property.x and property.y. Even if you didn't use the above named file that one of struts' users created, you can easily extend the DispatchAction (look at the source code for Struts on how to do this properly) to look through the HTTP ParameterMap, and look for parameters named *.x or *.y, either using regex or just parse them using the java tokenizer. You only need to find one, either .x or .y, to confirm a button push on the form. ImageButtonDispatchAction (already existing in the archives) already does this, except through the ActionMapping in struts-config.xml you specify what the button names on the form are in the 'parameter' attribute. Doing that, cuts down the time it'll take you to look through the HTTP parameter map. Hope this helps. Martin Wednesday, July 23, 2003, 11:59:23 PM, you wrote: SD Hello All, SD I request you to suggest solution for the following problem. SD I want to use LookupDispatchAction or DispatchAction class so that the framework can call my action class methods when user preses any button in the JSP page. If I use html:submit buttons the SD value (which is equal to method name) with it gets submitted and used to call appropriate method in the action class. I am using html:image for buttons. The problem with it is the value for SD these buttons doesn't get submitted and framework cannot understand the method name. Does that mean if I use html:image then I cannot use DispatchAction or LookupDispatchAction Class. Or If I SD want to use these classes then I cannot use graphical buttons? can anybody tell me how can I use these classes with html:image ? SD The main thing is, We don't want to use any peace of javascript code. SD Thanks in advance. SD Shashank S. Dixit SD Associate Software Consultant. SD Datamatics Ltd. SD SDF-1, SEEPZ, SD Andheri,Mumbai -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm
Adam, Even, i know the nature of all the attributes during design time itself. Assume, i have 50 attributes in general, i know how to validate each one of them, during design time. But, for a particular kind of Business object, i would be getting just 20 properties alone, and the rest of the properties will not be applicable to the business object. Thats why i was facing problem, while contructing the bean. I think, with struts-validator, i can define all the possible rules for the bean. I have to give a try ... Thanks, R Balaji Adam Hardy wrote: Concerning the validation, what you do depends on whether all the possible different validation mechanisms are limited to a defined set, or whether it is an unbounded set that you cannot limit at design time. On 08/24/2003 07:06 AM R Balaji wrote: well, in the jsp, i would be getting all the dynaproperties.. and be enumerating them while printing the keys and values in the UI. I managed to to do this, and able to display the bean details. I too realized that i should handle the reset method. I will try that. Yes, my business tier will give the information regarding the valid values of each attribute. I believe that i can use this for validating the properties. But i too do not know how far i can use dynavalidator and the validation framework. Do you have any suggestions other than my current dynamic bean population design ?. Regards, R Balaji Adam Hardy wrote: I read your solution for populating the dynaform. How do you display it in JSP? I mean, how does the JSP know what the field names are? I don't really know the internal workings of the dynavalidator form and how struts would populate the form bean with request parameters. You would probably have to do the same formbean initialization in the bean's reset method, otherwise the request parameters will probably not get saved to it. Once you get that far, then validation becomes an issue. At design time you don't what the fields of a form will be - but do you know how any particular type of field should be validated? If so, how do you know? Is that in the design? Adam On 08/23/2003 05:34 PM R Balaji wrote: Yes, Adam .. this is a valid point , that i need to consider. But, it is almost impossible to define a bean for each type of data, in my application. I need to use the dynabean and dynaclass , some how. I managed to find a solution for populating the bean , now i have to find a solution for validation too. Suggest me a suitable validation approach.. With Regards, R Balaji Adam Hardy wrote: I can see that you could just iterate over the unknown form properties in the JSP, but how would you label them? And when the form is submitted, how would you validate them? I think you would be better advised to add your list of properties as beans to your form. In each bean you could also have a label and a validation. my 2 cents. Adam On 08/23/2003 12:03 PM Mark Lowe wrote: You cant dynamically add properties to DynaActionForms. I'm not sure why you've a problem with just adding the fields to you form bean in struts config. I've demonstrated how to literally do what you want, but you'd have to specify the properties you want in you jsp anyway. But here goes You could create a new form bean copy the properties across from you old one and then add some new stuff.. DynaActionForm oldForm = (DynaActionForm) form; //get the map out and mess with this and life should be simpler that using the dynaBean Map oldFormMap = oldForm.getMap(); oldFormMap.put(statusChangeTime,A new Time); DynaActionForm newForm = new DynaActionForm(); BeanUtils.populate(newForm, oldFormMap); If this doesn't work you can try constructing all you dyna properties, having a DynaProperty[] array and then use the dynaBean constructer that takes a properties array. Cheers Mark On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote: Dear All, I have an application which returns a varity of properties, which can not be decided at design time. I would like to populate the Business data into a dynaValidatorForm and display them. In this case, it is not possible to specify all the properties as form-property. If i set properties, without specifying them in the struts-config.xml, i am getting exception as mentioned below. java.lang.IllegalArgumentException: Invalid property name 'statusChangeTime' at org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. java:598) at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV iewBean(ObjectDetailsHandler.java:63) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje ctDetails(ObjectDetailsHandler.java:49) at com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob jectDetailsAction.java:54) Please help me , in this regards, Thanks
Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm
Mark, This approach looks nice. Did you consider, populating the bean, on form submit ? ... one more thing is.. will the struts-validator go well with this ? R Balaji Mark Lowe wrote: Okay .. I've been thinking about this. I think it might work something like this.. form-property name=beans property=java.util.ArrayList / The arrayList will be a container for your beans with indexed properties. So in jsp we're thinking, or aiming for logic:iterate id=bean name=myForm property=beans bean:write name=bean property=key[%= index %] / html:text name=bean property=value[%= index %] / /logic:iterate So we have a bean thats mapped backed, or something here's some pseudo code. public class MyBean { private Map map; public Object[] getKeys() { return map.keySet().toArray(); } public Object[] getValues() { ArrayList list = new ArrayList(); Object[] keys = getKeys(); for(int i = 0;i keys.length;i++) { String value = map.get(keys[i].toString()); list.add(value); } return list.toArray(); } public String getKey(int i) { return keys[i].toString(); } public String getValue(int i) { String key = getKey(i); return map.get(key); } public void setKey(int i, String str) { keys[i] = str; } public void setValue(int i , String str) { map.put(getKey(i),str); } ... well you get the idea.. Am I tree barking, smoking crack or something but Its starting look possible.. el should help move the scriptlets out, but using indexed, mapped properties looks like it may do the job.. the bean could have a double sided array it returns to keep the keys and values in the correct order. The keys are after all the illusion that the properties have names, when really they are associated via index. When it comes time to write to a db or something the bean could return a map and the key=value pairs should all be there ready. Cheers mark On Saturday, August 23, 2003, at 06:51 PM, Adam Hardy wrote: I read your solution for populating the dynaform. How do you display it in JSP? I mean, how does the JSP know what the field names are? I don't really know the internal workings of the dynavalidator form and how struts would populate the form bean with request parameters. You would probably have to do the same formbean initialization in the bean's reset method, otherwise the request parameters will probably not get saved to it. Once you get that far, then validation becomes an issue. At design time you don't what the fields of a form will be - but do you know how any particular type of field should be validated? If so, how do you know? Is that in the design? Adam On 08/23/2003 05:34 PM R Balaji wrote: Yes, Adam .. this is a valid point , that i need to consider. But, it is almost impossible to define a bean for each type of data, in my application. I need to use the dynabean and dynaclass , some how. I managed to find a solution for populating the bean , now i have to find a solution for validation too. Suggest me a suitable validation approach.. With Regards, R Balaji Adam Hardy wrote: I can see that you could just iterate over the unknown form properties in the JSP, but how would you label them? And when the form is submitted, how would you validate them? I think you would be better advised to add your list of properties as beans to your form. In each bean you could also have a label and a validation. my 2 cents. Adam On 08/23/2003 12:03 PM Mark Lowe wrote: You cant dynamically add properties to DynaActionForms. I'm not sure why you've a problem with just adding the fields to you form bean in struts config. I've demonstrated how to literally do what you want, but you'd have to specify the properties you want in you jsp anyway. But here goes You could create a new form bean copy the properties across from you old one and then add some new stuff.. DynaActionForm oldForm = (DynaActionForm) form; //get the map out and mess with this and life should be simpler that using the dynaBean Map oldFormMap = oldForm.getMap(); oldFormMap.put(statusChangeTime,A new Time); DynaActionForm newForm = new DynaActionForm(); BeanUtils.populate(newForm, oldFormMap); If this doesn't work you can try constructing all you dyna properties, having a DynaProperty[] array and then use the dynaBean constructer that takes a properties array. Cheers Mark On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote: Dear All, I have an application which returns a varity of properties, which can not be decided at design time. I would like to populate the Business data into a dynaValidatorForm and display them. In this case, it is not possible to specify all the properties as form-property. If i set properties, without specifying them in the struts-config.xml, i am
Re: Issue in using struts-html-el tag
Hi Aattai, Well, all the configurations you made in your jsp are fine. in the html-el:text, you have mentioned that it should be populated to the assign property of the bean. But how will the el tag know, the name of the bean, this property belongs to ?. better you specify the name of the bean also html-el:text styleClass= smalltext name=***FormBean property=assigns value=${***FormBean.assign}/ Hope this helps, With Regards, R Balaji K.M.Prabhu wrote: Hi All, I am using struts-html-el tag in my jsp page for textarea. Steps i have followed.. 1. Put struts-el.jar in CLASSPATH or WEB-INF/lib (This jar would be present in $STRUTS_HOME/contrib/struts-el/lib) 2. Declare the prefix to be used in your jsp : [EMAIL PROTECTED] uri = http://jakarta.apache.org/struts/tags-html-el; prefix = html-el % The piece of code looks like this, [EMAIL PROTECTED] uri = http://jakarta.apache.org/struts/tags-html-el; prefix = html-el % form action=# table width=90% border=0 align=center cellpadding=2 cellspacing=1 tr td width=26% align=left valign=top class=textMessage :/td td height=30 html-el:text property=assign style=width:180 styleClass=formstyle/ /td /tr /table /form But i am getting the following exception while invoking it. Where i am making the mistake. The exception is, Apache Tomcat/4.0.4 - HTTP Status 500 - Internal Server Error *type* Exception report *message* _Internal Server Error_ *description* _The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request._ *exception* javax.servlet.ServletException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471) at org.apache.jsp.assignAlert$jsp._jspService(assignAlert$jsp.java:585) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1058) at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:451) at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:502) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext
Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm
well, in the jsp, i would be getting all the dynaproperties.. and be enumerating them while printing the keys and values in the UI. I managed to to do this, and able to display the bean details. I too realized that i should handle the reset method. I will try that. Yes, my business tier will give the information regarding the valid values of each attribute. I believe that i can use this for validating the properties. But i too do not know how far i can use dynavalidator and the validation framework. Do you have any suggestions other than my current dynamic bean population design ?. Regards, R Balaji Adam Hardy wrote: I read your solution for populating the dynaform. How do you display it in JSP? I mean, how does the JSP know what the field names are? I don't really know the internal workings of the dynavalidator form and how struts would populate the form bean with request parameters. You would probably have to do the same formbean initialization in the bean's reset method, otherwise the request parameters will probably not get saved to it. Once you get that far, then validation becomes an issue. At design time you don't what the fields of a form will be - but do you know how any particular type of field should be validated? If so, how do you know? Is that in the design? Adam On 08/23/2003 05:34 PM R Balaji wrote: Yes, Adam .. this is a valid point , that i need to consider. But, it is almost impossible to define a bean for each type of data, in my application. I need to use the dynabean and dynaclass , some how. I managed to find a solution for populating the bean , now i have to find a solution for validation too. Suggest me a suitable validation approach.. With Regards, R Balaji Adam Hardy wrote: I can see that you could just iterate over the unknown form properties in the JSP, but how would you label them? And when the form is submitted, how would you validate them? I think you would be better advised to add your list of properties as beans to your form. In each bean you could also have a label and a validation. my 2 cents. Adam On 08/23/2003 12:03 PM Mark Lowe wrote: You cant dynamically add properties to DynaActionForms. I'm not sure why you've a problem with just adding the fields to you form bean in struts config. I've demonstrated how to literally do what you want, but you'd have to specify the properties you want in you jsp anyway. But here goes You could create a new form bean copy the properties across from you old one and then add some new stuff.. DynaActionForm oldForm = (DynaActionForm) form; //get the map out and mess with this and life should be simpler that using the dynaBean Map oldFormMap = oldForm.getMap(); oldFormMap.put(statusChangeTime,A new Time); DynaActionForm newForm = new DynaActionForm(); BeanUtils.populate(newForm, oldFormMap); If this doesn't work you can try constructing all you dyna properties, having a DynaProperty[] array and then use the dynaBean constructer that takes a properties array. Cheers Mark On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote: Dear All, I have an application which returns a varity of properties, which can not be decided at design time. I would like to populate the Business data into a dynaValidatorForm and display them. In this case, it is not possible to specify all the properties as form-property. If i set properties, without specifying them in the struts-config.xml, i am getting exception as mentioned below. java.lang.IllegalArgumentException: Invalid property name 'statusChangeTime' at org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. java:598) at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV iewBean(ObjectDetailsHandler.java:63) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje ctDetails(ObjectDetailsHandler.java:49) at com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob jectDetailsAction.java:54) Please help me , in this regards, Thanks in Advance. With Regards, R Balaji - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm
Hi Mark, Thanks for your mail. I tried your, our first suggestion, but the BeanUtils.populate(), wont go well with this dynamic properties. It throws java.lang.NullPointerException at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926) at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808) at com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populateViewBean(ObjectDetailsAction.java:139) Actually, i am trying to display the properties of different ManagedResources. The will have different properties ( some may have 10, and others may have 30 properties, including few in this 10 ) ... so i can not pre-determine the properties, and specify them in the form-property tag. Only while fetching and populating the bean , i will get to know the list of properties to be displayed in the UI. This stops me from modeling a bean for the view data. Hope i m clear ... I am jst trying your second approach .. do you have any code snippet for that ... Thanks regards, R Balaji Mark Lowe wrote: You cant dynamically add properties to DynaActionForms. I'm not sure why you've a problem with just adding the fields to you form bean in struts config. I've demonstrated how to literally do what you want, but you'd have to specify the properties you want in you jsp anyway. But here goes You could create a new form bean copy the properties across from you old one and then add some new stuff.. DynaActionForm oldForm = (DynaActionForm) form; //get the map out and mess with this and life should be simpler that using the dynaBean Map oldFormMap = oldForm.getMap(); oldFormMap.put(statusChangeTime,A new Time); DynaActionForm newForm = new DynaActionForm(); BeanUtils.populate(newForm, oldFormMap); If this doesn't work you can try constructing all you dyna properties, having a DynaProperty[] array and then use the dynaBean constructer that takes a properties array. Cheers Mark On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote: Dear All, I have an application which returns a varity of properties, which can not be decided at design time. I would like to populate the Business data into a dynaValidatorForm and display them. In this case, it is not possible to specify all the properties as form-property. If i set properties, without specifying them in the struts-config.xml, i am getting exception as mentioned below. java.lang.IllegalArgumentException: Invalid property name 'statusChangeTime' at org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. java:598) at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV iewBean(ObjectDetailsHandler.java:63) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje ctDetails(ObjectDetailsHandler.java:49) at com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob jectDetailsAction.java:54) Please help me , in this regards, Thanks in Advance. With Regards, R Balaji - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm
wow, thanks mark. i managed to make the things working like this ,,, String className = viewBean.getDynaClass().getName(); FormPropertyConfig propConfig = null; Enumeration keys = viewData.keys(); while(keys.hasMoreElements()) { String key=(String)keys.nextElement(); String value = (String)viewData.getProperty(key); propConfig = new FormPropertyConfig(key,java.lang.String,value); config.addFormPropertyConfig(propConfig); } DynaActionFormClass beanClass= DynaActionFormClass.createDynaActionFormClass(config); viewBean = (DynaValidatorForm) beanClass.newInstance(); BeanUtils.populate(viewBean, viewData); it is working fine now Regards, b Mark Lowe wrote: Okay The code for creating a dynaBean etc is in the archieves when i messing around with dynaResultSet or whatever it was called. Then try creating a form property form the key-value pairs..BeanUtils is just useful short-hand. But thats irrelevant now i know what you're trying to do. You'll have an easier time by nesting beans as your form-property, and then i guess you beans will have to have a map or list style interface to pull generate your form. Please any snippets are demonstration of concept, I could be very wrong.. but something like this. Using indexed properties should help you stop having to define dynaBeans on the fly, which last time i played with doing that things got very slow. form-property name=resource type=java.util.ArrayList / ... public class ManagedResourceBean { private ArrayLIst list; public ArrayList getList() { return list; } getValue(int index) { return list.get(index).toString(); } setValue(String str) { list.add(str); } } .. ManagedResourceBean bean = new ManagedResourceBean(); iterator it = myResourcesFromMyModel.getResouces(); while(it.hasNext()) { bean.setValue(it.next()); } theForm.set(resource,bean.getList()); .. logic:iterate id=item name=myForm property=resource html:text name=item property=value[index] / /logic:iterate .. Some of the details are certainly wrong but I think the concept is okay. Cheers Mark On Saturday, August 23, 2003, at 12:22 PM, R Balaji wrote: Hi Mark, Thanks for your mail. I tried your, our first suggestion, but the BeanUtils.populate(), wont go well with this dynamic properties. It throws java.lang.NullPointerException at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926) at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808) at com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populateVi ewBean(ObjectDetailsAction.java:139) Actually, i am trying to display the properties of different ManagedResources. The will have different properties ( some may have 10, and others may have 30 properties, including few in this 10 ) ... so i can not pre-determine the properties, and specify them in the form-property tag. Only while fetching and populating the bean , i will get to know the list of properties to be displayed in the UI. This stops me from modeling a bean for the view data. Hope i m clear ... I am jst trying your second approach .. do you have any code snippet for that ... Thanks regards, R Balaji Mark Lowe wrote: You cant dynamically add properties to DynaActionForms. I'm not sure why you've a problem with just adding the fields to you form bean in struts config. I've demonstrated how to literally do what you want, but you'd have to specify the properties you want in you jsp anyway. But here goes You could create a new form bean copy the properties across from you old one and then add some new stuff.. DynaActionForm oldForm = (DynaActionForm) form; //get the map out and mess with this and life should be simpler that using the dynaBean Map oldFormMap = oldForm.getMap(); oldFormMap.put(statusChangeTime,A new Time); DynaActionForm newForm = new DynaActionForm(); BeanUtils.populate(newForm, oldFormMap); If this doesn't work you can try constructing all you dyna properties, having a DynaProperty[] array and then use the dynaBean constructer that takes a properties array. Cheers Mark On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote: Dear All, I have an application which returns a varity of properties, which can not be decided at design time. I would like to populate the Business data into a dynaValidatorForm and display them. In this case, it is not possible to specify all the properties as form-property. If i set properties, without specifying them in the struts-config.xml, i am getting exception as mentioned below. java.lang.IllegalArgumentException: Invalid property name 'statusChangeTime' at org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionFor m. java:598
Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm
Yes, Adam .. this is a valid point , that i need to consider. But, it is almost impossible to define a bean for each type of data, in my application. I need to use the dynabean and dynaclass , some how. I managed to find a solution for populating the bean , now i have to find a solution for validation too. Suggest me a suitable validation approach.. With Regards, R Balaji Adam Hardy wrote: I can see that you could just iterate over the unknown form properties in the JSP, but how would you label them? And when the form is submitted, how would you validate them? I think you would be better advised to add your list of properties as beans to your form. In each bean you could also have a label and a validation. my 2 cents. Adam On 08/23/2003 12:03 PM Mark Lowe wrote: You cant dynamically add properties to DynaActionForms. I'm not sure why you've a problem with just adding the fields to you form bean in struts config. I've demonstrated how to literally do what you want, but you'd have to specify the properties you want in you jsp anyway. But here goes You could create a new form bean copy the properties across from you old one and then add some new stuff.. DynaActionForm oldForm = (DynaActionForm) form; //get the map out and mess with this and life should be simpler that using the dynaBean Map oldFormMap = oldForm.getMap(); oldFormMap.put(statusChangeTime,A new Time); DynaActionForm newForm = new DynaActionForm(); BeanUtils.populate(newForm, oldFormMap); If this doesn't work you can try constructing all you dyna properties, having a DynaProperty[] array and then use the dynaBean constructer that takes a properties array. Cheers Mark On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote: Dear All, I have an application which returns a varity of properties, which can not be decided at design time. I would like to populate the Business data into a dynaValidatorForm and display them. In this case, it is not possible to specify all the properties as form-property. If i set properties, without specifying them in the struts-config.xml, i am getting exception as mentioned below. java.lang.IllegalArgumentException: Invalid property name 'statusChangeTime' at org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. java:598) at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV iewBean(ObjectDetailsHandler.java:63) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje ctDetails(ObjectDetailsHandler.java:49) at com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob jectDetailsAction.java:54) Please help me , in this regards, Thanks in Advance. With Regards, R Balaji - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm
yea, i just printed the details in the Ui. I looks great .. I will keep you posted if i get suceeded in submiting the form. regards, b Mark Lowe wrote: Nice.. Thats quite slick.. Also have you tried to submit the form yet? and print out its contents? I'd be interested to know.. Cheers Mark On Saturday, August 23, 2003, at 04:29 PM, R Balaji wrote: wow, thanks mark. i managed to make the things working like this ,,, String className = viewBean.getDynaClass().getName(); FormPropertyConfig propConfig = null; Enumeration keys = viewData.keys(); while(keys.hasMoreElements()) { String key=(String)keys.nextElement(); String value = (String)viewData.getProperty(key); propConfig = new FormPropertyConfig(key,java.lang.String,value); config.addFormPropertyConfig(propConfig); }DynaActionFormClass beanClass= DynaActionFormClass.createDynaActionFormClass(config); viewBean = (DynaValidatorForm) beanClass.newInstance(); BeanUtils.populate(viewBean, viewData); it is working fine now Regards, b Mark Lowe wrote: Okay The code for creating a dynaBean etc is in the archieves when i messing around with dynaResultSet or whatever it was called. Then try creating a form property form the key-value pairs..BeanUtils is just useful short-hand. But thats irrelevant now i know what you're trying to do. You'll have an easier time by nesting beans as your form-property, and then i guess you beans will have to have a map or list style interface to pull generate your form. Please any snippets are demonstration of concept, I could be very wrong.. but something like this. Using indexed properties should help you stop having to define dynaBeans on the fly, which last time i played with doing that things got very slow. form-property name=resource type=java.util.ArrayList / ... public class ManagedResourceBean { private ArrayLIst list; public ArrayList getList() { return list; } getValue(int index) { return list.get(index).toString(); } setValue(String str) { list.add(str); } } .. ManagedResourceBean bean = new ManagedResourceBean(); iterator it = myResourcesFromMyModel.getResouces(); while(it.hasNext()) { bean.setValue(it.next()); } theForm.set(resource,bean.getList()); .. logic:iterate id=item name=myForm property=resource html:text name=item property=value[index] / /logic:iterate .. Some of the details are certainly wrong but I think the concept is okay. Cheers Mark On Saturday, August 23, 2003, at 12:22 PM, R Balaji wrote: Hi Mark, Thanks for your mail. I tried your, our first suggestion, but the BeanUtils.populate(), wont go well with this dynamic properties. It throws java.lang.NullPointerException at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926 ) at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808) at com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populate Vi ewBean(ObjectDetailsAction.java:139) Actually, i am trying to display the properties of different ManagedResources. The will have different properties ( some may have 10, and others may have 30 properties, including few in this 10 ) ... so i can not pre-determine the properties, and specify them in the form-property tag. Only while fetching and populating the bean , i will get to know the list of properties to be displayed in the UI. This stops me from modeling a bean for the view data. Hope i m clear ... I am jst trying your second approach .. do you have any code snippet for that ... Thanks regards, R Balaji Mark Lowe wrote: You cant dynamically add properties to DynaActionForms. I'm not sure why you've a problem with just adding the fields to you form bean in struts config. I've demonstrated how to literally do what you want, but you'd have to specify the properties you want in you jsp anyway. But here goes You could create a new form bean copy the properties across from you old one and then add some new stuff.. DynaActionForm oldForm = (DynaActionForm) form; //get the map out and mess with this and life should be simpler that using the dynaBean Map oldFormMap = oldForm.getMap(); oldFormMap.put(statusChangeTime,A new Time); DynaActionForm newForm = new DynaActionForm(); BeanUtils.populate(newForm, oldFormMap); If this doesn't work you can try constructing all you dyna properties, having a DynaProperty[] array and then use the dynaBean constructer that takes a properties array. Cheers Mark On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote: Dear All, I have an application which returns a varity of properties, which can not be decided at design time. I would like to populate the Business data into a dynaValidatorForm and display them
How to dynamically decide the properties of the DynaValidator/DynaActionForm
Dear All, I have an application which returns a varity of properties, which can not be decided at design time. I would like to populate the Business data into a dynaValidatorForm and display them. In this case, it is not possible to specify all the properties as form-property. If i set properties, without specifying them in the struts-config.xml, i am getting exception as mentioned below. java.lang.IllegalArgumentException: Invalid property name 'statusChangeTime' at org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:598) at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateViewBean(ObjectDetailsHandler.java:63) at com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObjectDetails(ObjectDetailsHandler.java:49) at com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(ObjectDetailsAction.java:54) Please help me , in this regards, Thanks in Advance. With Regards, R Balaji - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing bean property values in Action Class--Possible???
yes, you can very well update the FormBean from the ActionClass . ex . *TestFormBean testForm= (TestFormBean) form; testForm.setNumberOfRows(1); *this formbean instance will be passed to the jsp page with request scope ... i belive this will help you . balaji guruprasad jakka wrote: Hi, Is there any way, where I could change the bean data from the formbean in the Action class and use it in the forwardind JSPs. J G Guru Prasad V sem, Information Technology, Bachelor of Engineering, National Institute of Technology Karnataka, Surathkal. ( formerly KREC ) Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use JSTL taglib with struts html taglib
Dear Joshua, The html tags does not understand that expressions were passed and needs to be evaluated. The html-el tags will evaluate the run time expressions , where you do not even need JSTL . please do this, i believe this will work, * html-el:checkbox property=myItems value=${basicView.itemId}/ * with regards, Balaji* * White, Joshua A (HTSC, CASD) wrote: I would like to use the struts html taglig to generate a bunch of checkboxes. While the following is not correct, it encapsulates what I would like to do: c:forEach items=${myForm.myInformationView} var=basicView html:checkbox property=myItems value=c:out value='${basicView.itemId}'//br * * * * /c:forEach I am looping throught the collection using the jstl forEach tag. The problem is that c:out is not evaluated as a runtime expression (actually, it is not evaluated at all). Using c:set to set a page level variable that you could use in a runtime expression does not work either. Is there a way to use both jstl and the struts html taglib here? How can it be done? Regards, Joshua This communication, including attachments, is for the exclusive use of addressee and may contain proprietary, confidential or privileged information. If you are not the intended recipient, any use, copying, disclosure, dissemination or distribution is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return email and delete this communication and destroy all copies. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Error Msg:Internal Server Error
check whether u have the *MessageResources.properties *in the right place and being configutred in the struts-config.xml. balaji gowri shankar wrote: Hi, This is Gowri Shankar.I tried to run a struts application (A basic web Application)which was given in the site --- http://www.javaranch.com/newsletter/Mar2002/newslettermar2002.jsp#struts I compiled the application and when i tried to run it I got the following error. Can anyone please help me out in fixing this bug. The error in the browser was Apache Tomcat/4.0.6 - HTTP Status 500 - Internal Server Error type Exception report message Internal Server Error description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request. exception javax.servlet.ServletException: Missing resources attribute org.apache.struts.action.MESSAGE at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471) at org.apache.jsp.LoginView$jsp._jspService(LoginView$jsp.java:365) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125) at java.lang.Thread.run(Thread.java:484) root cause javax.servlet.jsp.JspException: Missing resources attribute org.apache.struts.action.MESSAGE at org.apache.struts.taglib.MessageTag.doStartTag(MessageTag.java:360) at org.apache.jsp.LoginView$jsp._jspService(LoginView$jsp.java:76) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at
Re: Possible to dynamically set value of an html:select element?
Have you ever tried with heml-el:select, where you can pass such expresions . balaji David Benoff wrote: Pardon the newbie-ness but Ive searched the archives extensively and havent turned up anything on this. Any hints would be much appreciated. Id like to know whether there is any way to dynamically set the property attribute within an html:select element. The page Im working on iterates through a collection of User beans, each of which has its own collection of Role beans. Each user is displayed on a row with a dropdown that is populated with that users collection of roles. The user needs to select a single Role for each user displayed, and Id like to get the form returned as a HashMap with the username as the key and the rolename as the value. The relevant snippet is below: logic:iterate id=user name=userlist bean:write name=user property=username/ html:select property=rolemap(username) html:optionsCollection name=user property=roles value=rolename/ /html:select /logic:iterate My problem, of course, is that since property=rolemap(username) isnt dynamic, the key gets stored verbosely as username, which overwrites the value on each iteration, so the map always gets returned with a single value. My guess is theres a straightforward way to do this, but Ill be darned if I can find it. Id very much appreciate it if someone could point me in the right direction. Thanks, David Benoff --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.502 / Virus Database: 300 - Release Date: 7/18/2003
Re: Validator Problem when using Required
Adam Hardy wrote: R Balaji wrote: If i fail to give the userName it is prompting, that userName is required. But if i input only 2 characters for the userName, while all other ( some of the other ) fields are empty it prompts only about all other required fields, and not validating the *minlength* condition until all other required conditions get satisfied. I feel it should also validate the userName and prompt that the length is less than 5 chatacters. is there anything to define the precedence in the validation.xml ? .. will the minlength be validated only if all the required get satisfied. ?? I'm not sure but that's the way my validation functions as well. I imagine the validator has certain rules such as this built in so that you don't get overwhelmed with validation messages when you have complex validations to do. How can that be a problem though? I think it would be better if we prompt all the errors at once to the user. The user should not wait till entering the valid fields and then check for the validity of the entered values. The Required condition should take the precedence over all other condition for that *particular Field*. I too agree this , as there is not point in checking the length, when the user fails to enter the value at all. But my concern is, why should we wait till entering all *other* required fields, for checking the length of a Field. Can i do Complex validations, using the predefined rules like required, range .. etc .. ? Should i write my own rules by duplicating the predefined ones ? Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with struts-el
Hi Chuck, Well, the property parameter of the html-el:text stands for the name of the attribute in the form bean ,that should be updated while submitting the form. And the value attribute stands for the value to be displayed in the text field while loading the form. As per my understanding from your mail, i think you need to set the value attribute. But Canning, Chuck wrote: Hi, I found a message that says I might be missing a getter/setter field. Here is an excerpt from the page html-el:form name=deployCustomForm type=com.zilliant.management.ui.struts.deploy.CustomDeployForm action=/deploy/confirmDeployCustom.do / table c:forEach items=${testCaseDataBean[0].chosenRecDetails.decisionVars} var=decisionVar tr height=30 td class=greyTextc:out value=${decisionVar.key.name}/:nbsp;nbsp;/td td html-el:text property=*value(decisionVar.key.name)* I can not understand the use of *value() *method. Do you have getter setter methods and a property with the result of the *value() *method ??? . i believe that it should be some thing like, html-el:text name=deployCustomForm property=the property to be stored in the form bean value=${*decisionVar.key.name*}/ I think this would help you . Regards, Balaji
Validator Problem when using Required
Hi, I am using Struts Validator for validating my Application. i am using required for many of the fields and using minlength and maxlength for the userName field. my validation.xml reads like this, /Ex : field property=lastName depends=*required* arg0 key=validateform.lastname/ /field field property=userName depends=*required,minlength,maxlength* arg0 key=validateform.userName name=required/ arg0 key=validateform.userName name=minlength/ arg1 key=${var:minlength} name=minlength resource=false/ arg0 key=validateform.userName name=maxlength/ arg1 key=${var:maxlength} name=maxlength resource=false/ var var-nameminlength/var-name var-value5/var-value /var var var-namemaxlength/var-name var-value10/var-value /var /field field property=age depends=*required* arg0 key=validateform.age/ /field/ If i fail to give the userName it is prompting, that userName is required. But if i input only 2 characters for the userName, while all other ( some of the other ) fields are empty it prompts only about all other required fields, and not validating the *minlength* condition until all other required conditions get satisfied. I feel it should also validate the userName and prompt that the length is less than 5 chatacters. is there anything to define the precedence in the validation.xml ? .. will the minlength be validated only if all the required get satisfied. ?? please Help me. TIA, Balaji