You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jake Robb <jr...@sircon.com> on 2007/11/01 21:30:31 UTC

[S2] Display Tag? (2.0.11)

I've used DisplayTag with S1 before, with excellent results.  I'm also
using it in S2 in a few cases, and it's working fine.

However, now I want to use it to render a form.  Each row in the table
will contain a couple of input tags, and the table as a whole represents
a single List on my action.

Without DisplayTag, I can accomplish that as follows:

  <s:iterator value="rules" status="status" id="rule">
    <div class="resultRow${status.odd ? ' highlight' : ''}">
      <div class="name">
        <s:property value="name" />
      </div>
      <div class="value">
        <s:textfield name="%{'rules['+#status.index+'].value'}" label=""
size="90" />
      </div>
    </div>
  </s:iterator>


I converted the code above as follows:

  <display:table htmlId="rulesTable" list="rules" id="rule">
    <display:column title="Rule Name">
      <s:property value="name" />
    </display:column>
    <display:column title="Rule Name">
      <s:textfield name="rules[rule_rowNum].value" label="" size="90" />
    </display:column>
  </display:table>


But that didn't work, because DisplayTag doesn't push rule_rowNum onto
the stack.  So I added a push tag:

  <display:table htmlId="rulesTable" list="rules" id="rule">
    <s:push value="<%= rule_rowNum.toString() %>" id="rowNum"/>
    <display:column title="Rule Name">
      <s:property value="name" />
    </display:column>
    <display:column title="Rule Name">
      <s:textfield name="rules[rowNum].value" size="90" />
    </display:column>
  </display:table>


Then I discovered that s:push doesn't accept runtime expressions, just
like everything else in 2.0.11.

So, how do I accomplish this?  I guess I could keep it the old way, but
I'd really rather be consistent.

-Jake

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


RE: [S2] Display Tag? (2.0.11)

Posted by "Jiang, Jane (NIH/NCI) [C]" <ji...@mail.nih.gov>.
Hi Musachy,

Thank you so much for your post.  I had the same issue and came across
your email.  It worked great for me.  How did you find out about #attr?
Is that something specific to displaytag?

Thank you,

Jane

-----Original Message-----
From: Musachy Barroso [mailto:musachy@gmail.com] 
Sent: Thursday, November 01, 2007 5:04 PM
To: Struts Users Mailing List
Subject: Re: [S2] Display Tag? (2.0.11)

You can access the values published by displaytag using "#attr",  like:

<dt:table name="products" id="row" class="dt">
   <dt:column>
       <s:property value="#attr.row.name" />
   </dt:column>
</dt:table>

musachy

On 11/1/07, Jake Robb <jr...@sircon.com> wrote:
> I've used DisplayTag with S1 before, with excellent results.  I'm also
> using it in S2 in a few cases, and it's working fine.
>
> However, now I want to use it to render a form.  Each row in the table
> will contain a couple of input tags, and the table as a whole
represents
> a single List on my action.
>
> Without DisplayTag, I can accomplish that as follows:
>
>   <s:iterator value="rules" status="status" id="rule">
>     <div class="resultRow${status.odd ? ' highlight' : ''}">
>       <div class="name">
>         <s:property value="name" />
>       </div>
>       <div class="value">
>         <s:textfield name="%{'rules['+#status.index+'].value'}"
label=""
> size="90" />
>       </div>
>     </div>
>   </s:iterator>
>
>
> I converted the code above as follows:
>
>   <display:table htmlId="rulesTable" list="rules" id="rule">
>     <display:column title="Rule Name">
>       <s:property value="name" />
>     </display:column>
>     <display:column title="Rule Name">
>       <s:textfield name="rules[rule_rowNum].value" label="" size="90"
/>
>     </display:column>
>   </display:table>
>
>
> But that didn't work, because DisplayTag doesn't push rule_rowNum onto
> the stack.  So I added a push tag:
>
>   <display:table htmlId="rulesTable" list="rules" id="rule">
>     <s:push value="<%= rule_rowNum.toString() %>" id="rowNum"/>
>     <display:column title="Rule Name">
>       <s:property value="name" />
>     </display:column>
>     <display:column title="Rule Name">
>       <s:textfield name="rules[rowNum].value" size="90" />
>     </display:column>
>   </display:table>
>
>
> Then I discovered that s:push doesn't accept runtime expressions, just
> like everything else in 2.0.11.
>
> So, how do I accomplish this?  I guess I could keep it the old way,
but
> I'd really rather be consistent.
>
> -Jake
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


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


Re: [S2] Display Tag? (2.0.11)

Posted by ML...@abusinessware.com.
Or you can use Decorators :

                <display:table name="list" 
decorator="mypackage.decorator.MyDecorator">
                        <display:column titleKey="colName" 
property="attrNameNotInBean"/>
                </display:table>

public class MyDecorator extends TableDecorator {
        public String getAttrNameNotInBean() {
                MyBean bean = (MyBean) getCurrentRowObject();
                return "<input type=\"text\" name=\"" + bean.getName() + 
"\" size=\"90\" />";
        }
}

Michaël



"Musachy Barroso" <mu...@gmail.com> 
01/11/2007 22:12
Veuillez répondre à
"Struts Users Mailing List" <us...@struts.apache.org>


A
"Struts Users Mailing List" <us...@struts.apache.org>
cc

Objet
Re: [S2] Display Tag? (2.0.11)






You can access the values published by displaytag using "#attr",  like:

<dt:table name="products" id="row" class="dt">
   <dt:column>
       <s:property value="#attr.row.name" />
   </dt:column>
</dt:table>

musachy

On 11/1/07, Jake Robb <jr...@sircon.com> wrote:
> I've used DisplayTag with S1 before, with excellent results.  I'm also
> using it in S2 in a few cases, and it's working fine.
>
> However, now I want to use it to render a form.  Each row in the table
> will contain a couple of input tags, and the table as a whole represents
> a single List on my action.
>
> Without DisplayTag, I can accomplish that as follows:
>
>   <s:iterator value="rules" status="status" id="rule">
>     <div class="resultRow${status.odd ? ' highlight' : ''}">
>       <div class="name">
>         <s:property value="name" />
>       </div>
>       <div class="value">
>         <s:textfield name="%{'rules['+#status.index+'].value'}" label=""
> size="90" />
>       </div>
>     </div>
>   </s:iterator>
>
>
> I converted the code above as follows:
>
>   <display:table htmlId="rulesTable" list="rules" id="rule">
>     <display:column title="Rule Name">
>       <s:property value="name" />
>     </display:column>
>     <display:column title="Rule Name">
>       <s:textfield name="rules[rule_rowNum].value" label="" size="90" />
>     </display:column>
>   </display:table>
>
>
> But that didn't work, because DisplayTag doesn't push rule_rowNum onto
> the stack.  So I added a push tag:
>
>   <display:table htmlId="rulesTable" list="rules" id="rule">
>     <s:push value="<%= rule_rowNum.toString() %>" id="rowNum"/>
>     <display:column title="Rule Name">
>       <s:property value="name" />
>     </display:column>
>     <display:column title="Rule Name">
>       <s:textfield name="rules[rowNum].value" size="90" />
>     </display:column>
>   </display:table>
>
>
> Then I discovered that s:push doesn't accept runtime expressions, just
> like everything else in 2.0.11.
>
> So, how do I accomplish this?  I guess I could keep it the old way, but
> I'd really rather be consistent.
>
> -Jake
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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



Re: [S2] Display Tag? (2.0.11)

Posted by Musachy Barroso <mu...@gmail.com>.
You can access the values published by displaytag using "#attr",  like:

<dt:table name="products" id="row" class="dt">
   <dt:column>
       <s:property value="#attr.row.name" />
   </dt:column>
</dt:table>

musachy

On 11/1/07, Jake Robb <jr...@sircon.com> wrote:
> I've used DisplayTag with S1 before, with excellent results.  I'm also
> using it in S2 in a few cases, and it's working fine.
>
> However, now I want to use it to render a form.  Each row in the table
> will contain a couple of input tags, and the table as a whole represents
> a single List on my action.
>
> Without DisplayTag, I can accomplish that as follows:
>
>   <s:iterator value="rules" status="status" id="rule">
>     <div class="resultRow${status.odd ? ' highlight' : ''}">
>       <div class="name">
>         <s:property value="name" />
>       </div>
>       <div class="value">
>         <s:textfield name="%{'rules['+#status.index+'].value'}" label=""
> size="90" />
>       </div>
>     </div>
>   </s:iterator>
>
>
> I converted the code above as follows:
>
>   <display:table htmlId="rulesTable" list="rules" id="rule">
>     <display:column title="Rule Name">
>       <s:property value="name" />
>     </display:column>
>     <display:column title="Rule Name">
>       <s:textfield name="rules[rule_rowNum].value" label="" size="90" />
>     </display:column>
>   </display:table>
>
>
> But that didn't work, because DisplayTag doesn't push rule_rowNum onto
> the stack.  So I added a push tag:
>
>   <display:table htmlId="rulesTable" list="rules" id="rule">
>     <s:push value="<%= rule_rowNum.toString() %>" id="rowNum"/>
>     <display:column title="Rule Name">
>       <s:property value="name" />
>     </display:column>
>     <display:column title="Rule Name">
>       <s:textfield name="rules[rowNum].value" size="90" />
>     </display:column>
>   </display:table>
>
>
> Then I discovered that s:push doesn't accept runtime expressions, just
> like everything else in 2.0.11.
>
> So, how do I accomplish this?  I guess I could keep it the old way, but
> I'd really rather be consistent.
>
> -Jake
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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