Michael Westbay wrote:
> 
> Nick Pellow-san wrote:
> 
> > <logic:iterate collection="personList" id="element" property="">
> > <html:text property="personTable">
> >    <html:name>
> >       person<bean:write  name="element" property="personName"/>
> >    </html:name>
> >    <html:value>
> >       <bean:write name="element" property="personId"/>
> >    </html:value>
> > </html:text>
> > </logic:iterate>
> 
> Sorry for continuing, but...
> 
> The above sample has one thing that worries me.  The charage returns before and 
>after the actual value.  Won't they be included in the value of name?  So something 
>like:
> 
>   <logic:iterate collection="personList" id="element" property="">
>   <html:text property="personTable">
>      <html:name>person<bean:write  name="element" property="personName"/></html:name>
>      <html:value><bean:write name="element" property="personId"/></html:value>
>   </html:text>
>   </logic:iterate>
> 
> (Your mail software may wrap the <html:name>...</html:name> lines.  Please assume 
>them both to be on single lines.)
> 
> Might be more appropriate.  It's a minor detail, but one that could cause trouble 
>unless measures are taken to remove leading and trailing > [CR]s, which somebody, 
>wherewhere, for some odd reason, would probably want to preserve.


Yes, and here is another case where this could be used:

*** ... cut from struts-user ... ***

> Does anyone of the best approach for the following situation?
> 
> I wish to have a list of files for processing with a checkbox on the left
> hand side of each file to indicate if the file should be processed or not.
> I'm looking at how to do this in a single form with a <logic:iterator> tag
> to list the files.
> 
> If I use the <html:checkbox> tag the problem is that the names on the
> checkboxes are all the same and I can't distinguish between them.
> 
> Any ideas?

The solution allows you to configure an input tag at runtime. All that
is needed is 

1) for the current html:tags that require this,  need to implement my
RuntimeConfigurableTag and define two methods:

  public void setProperty(String property);
  public void setValue(String value);


NOTE: the checkbox tag already implements these methods.

2) See the attached classes. Build them into the struts.jar

3)
Add this to your struts-html.tld

    <tag>
        <info> This tag can be nested inside any RuntimeConfigurableTag
        and will set the name of
        of the request parameter passed to the server for that tag. The
        name will be the body of
        the tag.
    </info>
    <name>name</name>
    <tagclass>org.apache.struts.taglib.html.Name</tagclass>
    </tag>
    <tag>
    <info> This tag can be nested inside any RuntimeConfigurableTag
        and will set the value of
        of the request parameter passed to the server for that tag. The
        value will be the body of
        the tag.
    </info>
    <name>value</name>
    <tagclass>org.apache.struts.taglib.html.Value</tagclass>
    </tag>

4)Move the outputting of the html in the class that implemented
RuntimeConfigurableTag until the doAfterBodyTag() method.
I will attach what I did to the BaseFieldTag.

5) This is how you use it in the JSP:
        
        <html:text property="person">
          <html:name><bean:write name="element"
property="priorityId"/></html:name>
          <html:value><bean:write name="element"
property="name"/></html:value>
        </html:text>


Am not sure if this is the best, but it seems to work and it can be
re-used with nearly
all input tags. It is also backward compatible with the current
implementation.

It does not yet cater for re-population of fields.
Maybe a different approach such as that used by the html:options tag
would be more appropriate.


Cheers, 
Nick

RuntimeConfigurableTag.java

Name.java

BaseAttributeTag.java

Value.java

BaseFieldTag.java

Reply via email to