You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Rothfield <jo...@sfhypnosis.com> on 2002/08/02 18:46:01 UTC

field length for input tags

I have field definitions for my input fields defined in my Java classes
Previously, (using Velocity) I coded my fields like this:

        <input type="text" name="source" value="$!source"
size="$sourceField.fieldSize" maxlength="$sourceField.maxLength"     >

where $sourceField.fieldSize was substituted in by the templating engine.

Now I'm converting my forms to use struts so it will be something like:

          <html:text property="source" size="16" maxlength="16"/>

I understand that struts will populate the value automatically. How do you
recommend setting the
size and maxlength?

Thanks, John



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: field length for input tags

Posted by Mark Meytin <ma...@meytin.com>.
I guess this is the way:

<html:text property="source"
    size="<%= someBean.getSourceField().getFieldSize() %>"
    maxlength="<%= someBean.getSourceField().getMaxLength() %>" />

Not very pretty, but does the trick.  You may play with
someBean to make this more convinient or better structured.
I'd be curious to know if there's a better way with Struts,
like somehow request the property of the object by
just saying sourceField.fieldSize without escaping to
a RT Expression.

Regards,
-M-

John Rothfield wrote:

> I have field definitions for my input fields defined in my Java classes
> Previously, (using Velocity) I coded my fields like this:
> 
>         <input type="text" name="source" value="$!source"
> size="$sourceField.fieldSize" maxlength="$sourceField.maxLength"     >
> 
> where $sourceField.fieldSize was substituted in by the templating engine.
> 
> Now I'm converting my forms to use struts so it will be something like:
> 
>           <html:text property="source" size="16" maxlength="16"/>
> 
> I understand that struts will populate the value automatically. How do you
> recommend setting the
> size and maxlength?
> 
> Thanks, John
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>