I've distilled my issue down a bit. Now I can't get my indexed setters to
be called with the values from the page.

This is in my HTML created with the radio tag:
<tr>
<td class="tdLabel"></td>
<td
class="tdInput"
><input type="radio" name="variation[2000]" id="cart_variation_2000_500"
value="500"/><label for="cart_variation_2000_500">HOT</label>
<input type="radio" name="variation[2000]" id="cart_variation_2000_1500"
value="1500"/><label for="cart_variation_2000_1500">HOTTER</label>
</td>
</tr>



<tr>
<td class="tdLabel"></td>
<td
class="tdInput"
><select name="variation[13000]" id="cart_variation_13000_">
<option value="5500">Small</option>
<option value="5600">Medium</option>
<option value="5700">Large</option>


</select>

My setter in the destination action is:

     public void setVariation(HashMap<String, String> variationItem){

    logger.error("setVariation was called with variations");

    for (Map.Entry<String, String> entry : variationItem.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();

        logger.error(key + "=" + value);
    }


     }

It gets called but there is no data in the hashmap.

I also turned up the debugging in log4j and see the following:

07:05:39.556 DEBUG com.opensymphony.xwork2.ognl.SecurityMemberAccess -
Checking access for [target:
com.subecon.actions.commerce.CartAction@56dda392, member: public void
com.subecon.actions.commerce.CartAction.setVariation(java.util.HashMap),
property: variation]
07:05:39.556 DEBUG com.opensymphony.xwork2.ognl.SecurityMemberAccess -
Checking access for [target:
com.subecon.actions.commerce.CartAction@56dda392, member: public void
com.subecon.actions.commerce.CartAction.setVariation(java.util.HashMap),
property: variation]
07:05:39.557 DEBUG com.opensymphony.xwork2.ognl.SecurityMemberAccess -
Checking access for [target:
com.subecon.actions.commerce.CartAction@56dda392, member: public void
com.subecon.actions.commerce.CartAction.setVariation(java.util.HashMap),
property: variation]
07:05:39.557 DEBUG com.opensymphony.xwork2.ognl.SecurityMemberAccess -
Checking access for [target:
com.subecon.actions.commerce.CartAction@56dda392, member: public void
com.subecon.actions.commerce.CartAction.setVariation(java.util.HashMap),
property: variation]
07:05:39.557 DEBUG com.opensymphony.xwork2.ognl.SecurityMemberAccess -
Checking access for [target:
com.subecon.actions.commerce.CartAction@56dda392, member: public void
com.subecon.actions.commerce.CartAction.setVariation(java.util.HashMap),
property: variation]
07:05:39.557 DEBUG com.opensymphony.xwork2.ognl.SecurityMemberAccess -
Checking access for [target:
com.subecon.actions.commerce.CartAction@56dda392, member: public void
com.subecon.actions.commerce.CartAction.setVariation(java.util.HashMap),
property: variation]
07:05:39.557 ERROR com.subecon.actions.commerce.CartAction - setVariation
was called with variations
07:05:39.557 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter -
Retrieving convert for class [class
com.subecon.actions.commerce.CartAction] and property [variation.null]
07:05:39.557 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter -
Retrieving convert for class [class
com.subecon.actions.commerce.CartAction] and property [variation.null]

Is my method signature incorrect? Thank you!
dave







On Sun, Feb 25, 2018 at 8:57 AM, Dave Newton <davelnew...@gmail.com> wrote:

> 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 <djw...@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: davelnew...@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>
>

Reply via email to