Re: Struts Validation Rule for Single Java Bean form-property
Yujun- You can reference locale specific strings with bean:message.. for implementation details take a look at Rick Reumanns page http://www.reumann.net/struts/lesson3/step9.do and of course implementing locale specific strings dentified within ApplicationResources.properties (in your case it might be ApplicationResources_cn.properties file) ..I encourage you to look at the english example at http://www.reumann.net/struts/lesson3/step7.do Kind Regards, Martin- - Original Message - From: Laurie Harper [EMAIL PROTECTED] To: user@struts.apache.org Sent: Friday, October 28, 2005 8:28 PM Subject: Re: Struts Validation Rule for Single Java Bean form-property Yujun Liang wrote: Laurie, Thanks for the suggestion, just let you know I tried that and it seems not working, thus I am not sure whether this can be enhanced by Struts team since Java Bean inside Form Bean is a valid configuration and it is a very nice feature but there still something to imrprove. For example, it can't handle Locale and java.util.Date which I sent out another seperate email and you replied as well. But the Bean Population is handled by Struts so I can't register my converter unless I modify common BeanUtil. That, at least, is not true. See ConvertUtils.register() for registering custom converters on the default ConvertUtilsBean / BeanUtilsBean combo. Just make sure you register your converter during startup (using a context listener, servlet or Struts plugin) so they're available when form processing starts. L. Thanks. Regards Yujun Liang [EMAIL PROTECTED] (0408) 467 448 - Original Message - From: Laurie Harper [EMAIL PROTECTED] To: user@struts.apache.org Sent: Saturday, October 29, 2005 1:51 AM Subject: Re: Struts Validation Rule for Single Java Bean form-property Hmm, I'm not sure how to specify the validation rules with that configuration; you could try with field property=mybean.creationTime depends=... L. Yujun Liang wrote: Hello, I define a single Java Bean Form Bean, do you know how to define the validation rule? Thanks. Regards Yujun Liang [EMAIL PROTECTED] (0408) 467 448 1. Form Bean Definition, form-bean name=myForm type=org.apache.struts.validator.DynaValidatorForm form-property name=mybean type=com.mycompany.myproject.bean.MyBean/ /form-bean 2. Java Bean, package com.mycompany.myproject.bean; import java.io.Serializable; import java.sql.Timestamp; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; public class MyBean implements Serializable { private long interchangeId; private Timestamp creationTime; private String originatingChannel; public long getInterchangeId() { return this.interchangeId; } public void setInterchangeId(long interchangeId) { this.interchangeId = interchangeId; } public Timestamp getCreationTime() { return this.creationTime; } public void setCreationTime(Timestamp creationTime) { this.creationTime = creationTime; } public String getOriginatingChannel() { return this.originatingChannel; } public void setOriginatingChannel(String originatingChannel) { this.originatingChannel = originatingChannel; } } 3. HTML Form input name=mybean.creationTime type=text size=30 maxlength=30 value=25/10/2005 input name=mybean.originatingChannel type=text size=40 maxlength=40 value=originating channel1 input name=mybean.originatingChannelUserId type=text size=60 maxlength=60 value=originating_channel_userid1 - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Validation Rule for Single Java Bean form-property
Martin, Thanks for your help. My problem was not displaying the bean. What I wanted to know is whether there is a way to validate the property of the Java Bean defined in the form bean. How to define the validation rule for input name=mybean.creationTime Source code. 1. Form Bean Definition, form-bean name=myForm type=org.apache.struts.validator.DynaValidatorForm form-property name=mybean type=com.mycompany.myproject.bean.MyBean/ /form-bean 2. Java Bean, *package* com.mycompany.myproject.bean; * * *import* java.io.Serializable; * * *import* java.sql.Timestamp; * * *import* org.apache.commons.lang.builder.EqualsBuilder; * * *import* org.apache.commons.lang.builder.HashCodeBuilder; * * *import* org.apache.commons.lang.builder.ToStringBuilder; *public* *abstract* *class* MyBean *implements* Serializable { * private* *long* interchangeId; * private* Timestamp creationTime; * private* String originatingChannel; * public* *long* getInterchangeId() { * return* *this*.interchangeId; } * public **void* setInterchangeId(*long* interchangeId) { * this*.interchangeId = interchangeId; } * public* Timestamp getCreationTime() { * return* *this*.creationTime; } * * * public* *void* setCreationTime(Timestamp creationTime) { * this*.creationTime = creationTime; } * public* String getOriginatingChannel() { * return* *this*.originatingChannel; } * public* *void* setOriginatingChannel(String originatingChannel) { * this*.originatingChannel = originatingChannel; } } 3. HTML Form input name=mybean.creationTime type=text size=30 maxlength=30 value=25/10/2005 input name=mybean.originatingChannel type=text size=40 maxlength=40 value=originating channel1 input name=mybean.originatingChannelUserId type=text size=60 maxlength=60 value=originating_channel_userid1 On 10/29/05, Martin Gainty [EMAIL PROTECTED] wrote: Yujun- You can reference locale specific strings with bean:message.. for implementation details take a look at Rick Reumanns page http://www.reumann.net/struts/lesson3/step9.do and of course implementing locale specific strings dentified within ApplicationResources.properties (in your case it might be ApplicationResources_cn.properties file) ..I encourage you to look at the english example at http://www.reumann.net/struts/lesson3/step7.do Kind Regards, Martin- - Original Message - From: Laurie Harper [EMAIL PROTECTED] To: user@struts.apache.org Sent: Friday, October 28, 2005 8:28 PM Subject: Re: Struts Validation Rule for Single Java Bean form-property Yujun Liang wrote: Laurie, Thanks for the suggestion, just let you know I tried that and it seems not working, thus I am not sure whether this can be enhanced by Struts team since Java Bean inside Form Bean is a valid configuration and it is a very nice feature but there still something to imrprove. For example, it can't handle Locale and java.util.Date which I sent out another seperate email and you replied as well. But the Bean Population is handled by Struts so I can't register my converter unless I modify common BeanUtil. That, at least, is not true. See ConvertUtils.register() for registering custom converters on the default ConvertUtilsBean / BeanUtilsBean combo. Just make sure you register your converter during startup (using a context listener, servlet or Struts plugin) so they're available when form processing starts. L. Thanks. Regards Yujun Liang [EMAIL PROTECTED] (0408) 467 448 - Original Message - From: Laurie Harper [EMAIL PROTECTED] To: user@struts.apache.org Sent: Saturday, October 29, 2005 1:51 AM Subject: Re: Struts Validation Rule for Single Java Bean form-property Hmm, I'm not sure how to specify the validation rules with that configuration; you could try with field property=mybean.creationTime depends=... L. Yujun Liang wrote: Hello, I define a single Java Bean Form Bean, do you know how to define the validation rule? Thanks. Regards Yujun Liang [EMAIL PROTECTED] (0408) 467 448 1. Form Bean Definition, form-bean name=myForm type=org.apache.struts.validator.DynaValidatorForm form-property name=mybean type=com.mycompany.myproject.bean.MyBean/ /form-bean 2. Java Bean, package com.mycompany.myproject.bean; import java.io.Serializable; import java.sql.Timestamp; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; public class MyBean implements Serializable { private long interchangeId; private Timestamp creationTime; private String originatingChannel; public long getInterchangeId() { return this.interchangeId; } public void setInterchangeId(long interchangeId) { this.interchangeId = interchangeId; } public Timestamp getCreationTime() { return this.creationTime; }
Re: Problem with logic:iterate (and nested:iterate) and indexed form items - Help required
Thanks for that - but I think I've not explained my problem properly. The problem is that the bean containing the data is NOT the one in the inner loop but the bean iterated through in the outer loop: logic:iterate name=applicationForm property=familymembers id=familymmber type=application.FamilyMember I want to be able to access as from within the inner loop. familymembers[0].surname, familymembers[0].forename, familymembers[1].surname, etc. The reason for this is that the form needs to show and allow editing of different data depending on who is accessing it. Yeah, I know it makes things complicated but it's what THEY want. The inner iterate is around a form configuration bean which describes the data which should be displayed: logic:iterate name=applicationForm property=familyItems id=formItem type=utils.InputItem InputItem has fields which describe the type of input field to be used and whether it is displayed, readonly, mandatory, etc. i.e. inputitem is an array with entries something like - there are other fields to hold any option lists for select items, etc. but those aren't really relevant to this problem. inputitem[0] property=surname readonly=false size=30 type=text mandatory=true inputitem[1] property=forename readonly=false size=30 type=text mandatory=true and I want to end up with html like this. !-- First Row -- input type=text name=familymembers[0].forename value= input type=text name=familymembers[0].surname value= !-- 2nd row -- input type=text name=familymembers[1].forename value= input type=text name=familymembers[1].surname value= but because the iterator count is picked up from the inner loop - I end up with !-- First Row -- input type=text name=familymembers[0].forename value= input type=text name=familymembers[1].surname value= !-- 2nd row -- input type=text name=familymembers[0].forename value= input type=text name=familymembers[1].surname value= !-- 3rd row -- input type=text name=familymembers[0].forename value= input type=text name=familymembers[1].surname value= I've done this successfully using a similar technique when there is a single data item to be edited but this form needs to be able to edit multiple rows at once and I'm hitting a problem with the iterator. I guess what I really need is a way to iterate round the inner loop without the counter used for indexing being increased. Again, thanks for any help anyone can give. Mike Murray Collingwood wrote: Hi Mike Maybe I'm simplifying it somewhat and I'm not sure of your form-bean structure, however the outer loop should loop through 'familymembers' as it is looping it should set a form-bean for the inner loop identifying a 'familymember'. I also like to add the type here - helps my inline documentation. So, outer loop should be: logic:iterate name=applicationForm property=familymembers id=familymember type=controller.form.FamilyMemberForm Then we can add the inner loop in a similar manner, referencing the 'familymember' defined in the outerloop: logic:iterate name=familymember id=familyitem type=controller.form.FamilyItemForm Finally we can then display the input box for these items: html:text name=familyItem property=dataProperty size=${familyItem.size} readonly=${familyItem.readonly} Maybe this is too simplistic, sorry if I've missed the point somewhere. Kind regards mc On 28 Oct 2005 at 14:01, Mike Manley wrote: Hi, I have a problem trying to create a multi row edit form which has to be able to dynamically decide which columns should be displayed for edit. My jsp uses the code below. logic:iterate name=applicationForm property=familymembers id=familymembers tr logic:iterate name=applicationForm property=familyItems id=formItem td logic:notEmpty name=formItem % InputItem inputItem = (InputItem)formItem; % logic:equal name=formItem property=type value=text html:text size=%= inputItem.getSize() % readonly=%= inputItem.isReadonly()% name=familymembers property=%= inputItem.getDataProperty() % indexed=true/ /logic:equal /td /logic:iterate /td /logic:iterate The outer iterate is the bean holding the data - in this case a list of family members - name, gender, date of birth. The inner iterate is the list of fields to be displayed for each, My problems is that when this is rendered as html - the index values generated use the index of the inner iterate not the outer one - so I get tr td input type=text name=familymembers[0].forename value= /td td input type=text name=familymembers[1].surname value= /td /tr tr td input type=text name=familymembers[0].forename value= /td td input type=text name=familymembers[1].surname value= /td /tr whereas what I want is
multibox error
Hello I am using TC5.5.9,JSTL1.1,Struts1.2 With this code: table width=476 height=110 border=1 tr tdnbsp;/td tdhtml:multibox property=strArray value=Value1//td tdnbsp;/td /tr tr tdnbsp;/td tdnbsp;/td tdnbsp;/td /tr /table I have made sure my actionForm has the s/getter for checkbox1, checkbox2 strArray. Made sure the reset is setting the booleans to false. The page comes up without the html:multibox tag, so everything else is correct. Except for the error below. It seems like a tag library issue. Any and all insight welcomed. tia. I am getting javax.servlet.ServletException: Cannot find bean under name org.apache.struts.taglib.html.BEAN org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781) org.apache.jsp.jsp2_jsp._jspService(org.apache.jsp.jsp2_jsp:107) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN org.apache.struts.taglib.html.MultiboxTag.doEndTag(MultiboxTag.java:195) org.apache.jsp.jsp2_jsp._jspx_meth_html_multibox_0(org.apache.jsp.jsp2_jsp:125) org.apache.jsp.jsp2_jsp._jspService(org.apache.jsp.jsp2_jsp:88) __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to use Email Templates for struts?
Hi, I want to send my struts-1.2.7 application emails using templates. Which template engine should I use? Zsolt - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use Email Templates for struts?
Zsolt- Most of the Mail Templaing engines I have seen cost money But there is a shareware template library available at jsourcery http://jsourcery.com/output/java.net/atleap/0.5-rc1/com/blandware/atleap/model/core/MailTemplate.html HTH, Martin- - Original Message - From: Zsolt [EMAIL PROTECTED] To: Struts Users Mailing List struts-user@jakarta.apache.org Sent: Saturday, October 29, 2005 12:45 PM Subject: How to use Email Templates for struts? Hi, I want to send my struts-1.2.7 application emails using templates. Which template engine should I use? Zsolt - 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 use Email Templates for struts?
You can use velocity (http://jakarta.apache.org/velocity/) for generating your templates. When you're done parsing you feed it to the JavaMail API. Velocity is a very powerful template engine and you can even use is for Struts' Views. good luck, Martijn Martin Gainty wrote: Zsolt- Most of the Mail Templaing engines I have seen cost money But there is a shareware template library available at jsourcery http://jsourcery.com/output/java.net/atleap/0.5-rc1/com/blandware/atleap/model/core/MailTemplate.html HTH, Martin- - Original Message - From: Zsolt [EMAIL PROTECTED] To: Struts Users Mailing List struts-user@jakarta.apache.org Sent: Saturday, October 29, 2005 12:45 PM Subject: How to use Email Templates for struts? Hi, I want to send my struts-1.2.7 application emails using templates. Which template engine should I use? Zsolt - 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] -- 31.69 nHz = once a year - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use Email Templates for struts?
You can also just use basic JSP technology. You can use a servlet include to retrieve the output from a JSP, which could your mail. __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Lenya/Struts
Has anyone integrated a STRUTS webapp with Lenya? I am curently working through the least painful way to do it and any input would be helpful.. Thanks, Jim - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
jps:useBean documentation?
Hello, This question may seems stupid but where is the documentation the JSP tags? There is the doc at http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html for the JSTL but the tag jsp:useBean is not there like a lot of others. So where are they documented? -- A+ Pierre - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with logic:iterate (and nested:iterate) and indexed form items - Help required
Hi Mike Thats easy. Outer loop needs to specify the indexId parameter as in: logic:iterate name=applicationForm property=familymembers id=familymmber type=application.FamilyMember indexId=memberIndex Then you can use whatever inner loop (or loops) you want. logic:iterate something else Inside here you can refer to the 'memberIndex' as in: html:text name=familymembers[${memberIndex}].forename HTH Cheers mc On 29 Oct 2005 at 15:29, Mike Manley wrote: Thanks for that - but I think I've not explained my problem properly. The problem is that the bean containing the data is NOT the one in the inner loop but the bean iterated through in the outer loop: logic:iterate name=applicationForm property=familymembers id=familymmber type=application.FamilyMember I want to be able to access as from within the inner loop. familymembers[0].surname, familymembers[0].forename, familymembers[1].surname, etc. The reason for this is that the form needs to show and allow editing of different data depending on who is accessing it. Yeah, I know it makes things complicated but it's what THEY want. The inner iterate is around a form configuration bean which describes the data which should be displayed: logic:iterate name=applicationForm property=familyItems id=formItem type=utils.InputItem InputItem has fields which describe the type of input field to be used and whether it is displayed, readonly, mandatory, etc. i.e. inputitem is an array with entries something like - there are other fields to hold any option lists for select items, etc. but those aren't really relevant to this problem. inputitem[0] property=surname readonly=false size=30 type=text mandatory=true inputitem[1] property=forename readonly=false size=30 type=text mandatory=true and I want to end up with html like this. !-- First Row -- input type=text name=familymembers[0].forename value= input type=text name=familymembers[0].surname value= !-- 2nd row -- input type=text name=familymembers[1].forename value= input type=text name=familymembers[1].surname value= but because the iterator count is picked up from the inner loop - I end up with !-- First Row -- input type=text name=familymembers[0].forename value= input type=text name=familymembers[1].surname value= !-- 2nd row -- input type=text name=familymembers[0].forename value= input type=text name=familymembers[1].surname value= !-- 3rd row -- input type=text name=familymembers[0].forename value= input type=text name=familymembers[1].surname value= I've done this successfully using a similar technique when there is a single data item to be edited but this form needs to be able to edit multiple rows at once and I'm hitting a problem with the iterator. I guess what I really need is a way to iterate round the inner loop without the counter used for indexing being increased. Again, thanks for any help anyone can give. Mike Murray Collingwood wrote: Hi Mike Maybe I'm simplifying it somewhat and I'm not sure of your form-bean structure, however the outer loop should loop through 'familymembers' as it is looping it should set a form-bean for the inner loop identifying a 'familymember'. I also like to add the type here - helps my inline documentation. So, outer loop should be: logic:iterate name=applicationForm property=familymembers id=familymember type=controller.form.FamilyMemberForm Then we can add the inner loop in a similar manner, referencing the 'familymember' defined in the outerloop: logic:iterate name=familymember id=familyitem type=controller.form.FamilyItemForm Finally we can then display the input box for these items: html:text name=familyItem property=dataProperty size=${familyItem.size} readonly=${familyItem.readonly} Maybe this is too simplistic, sorry if I've missed the point somewhere. Kind regards mc On 28 Oct 2005 at 14:01, Mike Manley wrote: Hi, I have a problem trying to create a multi row edit form which has to be able to dynamically decide which columns should be displayed for edit. My jsp uses the code below. logic:iterate name=applicationForm property=familymembers id=familymembers tr logic:iterate name=applicationForm property=familyItems id=formItem td logic:notEmpty name=formItem % InputItem inputItem = (InputItem)formItem; % logic:equal name=formItem property=type value=text html:text size=%= inputItem.getSize() % readonly=%= inputItem.isReadonly()% name=familymembers property=%= inputItem.getDataProperty() % indexed=true/ /logic:equal /td /logic:iterate /td /logic:iterate The outer iterate is the bean holding the data
problems with struts html tag lib
I am trying to include a %= variable % type thing in an html:submit tag and it doesn't evaluate the %= variable % is there a way to make it evaluate this? Or is there a way to include dynamic contect in this tag. In this case it is inside a loop and variable changes each time through the loop. Here is the actual code, the second line prints out the proper value. bean:define id=key name=row property=userPrefId/bean:define %= key % html:submit onclick=setWKey('defaultFilter',%= key %); value=Default/ and this renders as: 15 input type=submit value=Default onclick=setWKey('defaultFilter',%= key %); and I would like it to render as 15 input type=submit value=Default onclick=setWKey('defaultFilter',15); Thanks in advance. Troy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]