struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <davelnew...@gmail.com>
Subject Re: Dynamically generating multiple sets of radio buttons
Date Sun, 25 Feb 2018 14:57:30 GMT
It’s not entirely clear to me what you’re asking.

`getItemList` will return whatever it returns—if the logic for what should
return lies in the view layer then it’s an architectural problem.

If you need to return two lists then you should have two list getters. If
the view layer *presentation* of the list varies by list content then the
list should be presented in a structure that represents that, e.g.,

    Class ViewList {
        String representation; // e.g., “radio”, “dropdown”, etc.
        List items; // The things to show
    }

If it depends on actions *taken* in the view layer, e.g., something
JavaScript-y, then all this is out the window and we’d need more
information.

Dave

On Sat, Feb 24, 2018 at 5:00 PM Dave Weis <djweis@sjdjweis.com> wrote:

> Hello
>
> I am trying to make multiple sets of radio buttons with independent lists
> of valid options. The options are all generated dynamically.
>
> I'm having trouble figuring out how to declare the item list provider in my
> java code. I have it working fine for a single item. With the sample below
> I get the same list for both my radio buttons and my dropdown but I need to
> be able to modify the list returned based on which line of input I'm on.
>
> Thank you
> dave
>
>
>
>
>
> <s:iterator value="product.variations">
>
> <table>
> <!--  variation stuff -->
>
> <tr>
> <td colspan="2">
> we have a variation <s:property value="name" />
> </td>
> </tr>
>
> <s:if test="display == 'radio'">
>
> <s:radio key="name"   list="itemList"   />
>
> </s:if>
>
> <s:if test="display == 'dropdown'">
>
> <s:select list="itemList" key="name"></s:select>
>
> </s:if>
>
> </table>
>
> </s:iterator>
>
>
>
> public ArrayList<String> getItemList() {
>
> logger.debug("get item list");
> ArrayList<String> retval = new ArrayList<String>();
> retval.add("the first option");
> retval.add("the second option");
> return retval;
> }
>
-- 
e: davelnewton@gmail.com
m: 908-380-8699
s: davelnewton_skype
t: @dave_newton <https://twitter.com/dave_newton>
b: Bucky Bits <http://buckybits.blogspot.com/>
g: davelnewton <https://github.com/davelnewton>
so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message