You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by tr...@gmail.com on 2006/01/10 02:44:40 UTC

Should an attribute add to tag?

In WriteTag.java
// ......
    protected int abbreviate = 0;

    public int getAbbreviate() {
        return abbreviate;
    }

    public void setAbbreviate(int abbreviate) {
        this.abbreviate = abbreviate;
    }
// ......
public int doStartTag() throws JspException {
// ...
         if (abbreviate > 0) {
            output = StringUtils.abbreviate(output, abbreviate);
        }

        // Print this property value to our output writer, suitably filtered

        if (filter) {
//...
}

And the tag:
        <attribute>
            <name>abbreviate</name>
            <required>false</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>

Then  we can use <bean:write name="somename" abbreviate="length"/> for short
text we want.

Re: Should an attribute add to tag?

Posted by Rahul Akolkar <ra...@gmail.com>.
On 1/9/06, truncatei@gmail.com <tr...@gmail.com> wrote:
> In WriteTag.java
> // ......
<snip/>
> // ...
>         if (abbreviate > 0) {
>            output = StringUtils.abbreviate(output, abbreviate);
>        }
>
<snap/>
>
> Then  we can use <bean:write name="somename" abbreviate="length"/> for short
> text we want.
>
<snip/>

FWIW, I think ellipsis can be quite useful in some situations. You'll
probably have better luck of this getting accepted if you:

 * Attach a patch to an enhancement request filed in Bugzilla [1]
under product: Struts, component: Taglibs
 * Inline the 4-odd lines of StringUtils.abbreviate code
 * I've never liked the IllegalArgumentException so maybe have length
be the length without the ellipsis, thats upto you ;-)

-Rahul

[1] http://issues.apache.org/bugzilla/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org