I18N and forms
I have been working on internationalizing my struts app. I just noticed that the form:submit tags' label is the value used for the property when submitted. If I understand correctly, this means that I can't use a bean:message tag to set the label, and a separate constant value for the property value on submission, which of course means that if I want my buttons to localize properly, I need really ugly handling code in my action classes.. Is there something I am missing? Or does anyone have a good way of working around this? Thanks, Mishkin. S/MIME Cryptographic Signature
Re: Hmm. Using last nights build...
I pulled down jakarta-struts-20010106.zip, the binary. Mishkin. "Steven D. Wilkinson" wrote: I'm using src distribution jakarta-struts-src-20010106.zip and I'm working fine. When you say last night are you speaking of jakarta-src-20010105.zip or the binary. S/MIME Cryptographic Signature
Re: Help: logic:iterate and form input fields
How does your orderform bean look? What are the method signatures for the items property? Thanks, Mishkin. Chandan Kulkarni wrote: I have this working now...Here's how I got this workingI'm including my BeanUtils.java.Here's how my jsp looks (the form:text> does not work as expected...I had to use the input tag...) TABLE WIDTH=100% border=1> TR> TH> Item Name /th> TH> Quantity /TH> /TR>% int count=0; %> logic:iterate id="orderlist" name="orderform" property="items" length="2"> tr> TD> input TYPE="TEXT" name="%= "items[" + count + "].itemName" %>" value="%= ((OrderItem)orderlist).getItemName() %>" /> /td> TD> input TYPE="TEXT" name="%= "items[" + count++ + "].quantity" %>" value="%= ((OrderItem)orderlist).getQuantity() %>" /> /td> /TR> /logic:iterate> /TABLE> The name is the nested and indexed name. The value field needs to be explicitly set to get the value from the bean.The changes I made to BeanUtils.java isI commented out this code inpublic static void populate(Object bean, String prefix, String suffix, HttpServletRequest request) /* CK: int subscript = stripped.lastIndexOf("["); if (subscript >= 0) // Remove subscript expression stripped = stripped.substring(0, subscript); CK: */ This keeps the indexed part of the nameAnd then in public static void populate(Object bean, Hashtable properties)Added this code // Check to see if the name is nested or indexed - then use PropertyUtils.setProperty int indexed = name.lastIndexOf("["); int nested = name.lastIndexOf("."); if ((indexed >= 0) || (nested >= 0)) { try { PropertyUtils.setProperty( bean, name, Array.get(value, 0)); } catch( java.lang.NoSuchMethodException e ) { } continue; } To handle the nested and indexed names by calling PropertyUtils.setProperty...Good luck, -Chandan Kulkarni. S/MIME Cryptographic Signature
Re: Help: logic:iterate and form input fields
Actually, I think I can add some clarification to this issue as I am encountering what I see as a similar problem. The basic goal is to create a form where there are a variable number of entries, all of which are the same type. The number of entries is determined at run-time, for example from rows in a database table. An example scenario would look something like this. Your Shopping Cart: ITEM: QUANTITY: Pencil 1___ Eraser 1___ Cheese 1___ (The quantities are text fields.) The list of items is generated at run-time from the things a person has clicked into their shopping cart, and the quantities are set at check-out time (by the user). The problem is that the iterate and form tags dont seem to work together for indexed properties. This is partially a problem with the underlying html. Each text field in a form needs a different name. In order to have these fields correspond to a specific index value in an indexed property, the names of the fields need to be parsed. The html might look something like this: form ... > table> tr> td>ITEM:/td>td>Quantity/td> /tr> tr> td>Pencil/td>td>input type="text" name="item000" value="1">/td> /tr> tr> td>Pencil/td>td>input type="text" name="item001" value="1">/td> /tr> tr> td>Pencil/td>td>input type="text" name="item002" value="1">/td> /tr> /table> ... /form> When the submit button was hit, the request parameters would be parsed. I have just started working on this problem. Mishkin. Chandan Kulkarni wrote: Yes...same idea... -Original Message- From: Ted Husted [EMAIL PROTECTED]> To: Struts List [EMAIL PROTECTED]> Date: Wednesday, December 27, 2000 10:36 AM Subject: Re: Help: logic:iterate> and form input fields Are you trying to do something like this order form (Javascript)https://public.wxxi.org/schedules/fm/voice-order.htmThis only shows one item, but the idea is that there would be one line for each item in a small inventory. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel 716 425-0252; Fax 716 223-2506. -- http://www.husted.com/ S/MIME Cryptographic Signature