Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9ABD4200BB4 for ; Tue, 1 Nov 2016 20:03:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 99636160ADA; Tue, 1 Nov 2016 19:03:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E2A00160B02 for ; Tue, 1 Nov 2016 20:02:59 +0100 (CET) Received: (qmail 45548 invoked by uid 500); 1 Nov 2016 19:02:58 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 45465 invoked by uid 99); 1 Nov 2016 19:02:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2016 19:02:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 927BC2C2A6E for ; Tue, 1 Nov 2016 19:02:58 +0000 (UTC) Date: Tue, 1 Nov 2016 19:02:58 +0000 (UTC) From: "Lukasz Lenart (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (WW-4702) List based parameters no longer work when there is only one value. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 01 Nov 2016 19:03:00 -0000 [ https://issues.apache.org/jira/browse/WW-4702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15626355#comment-15626355 ] Lukasz Lenart commented on WW-4702: ----------------------------------- Probably not but I would like to add a new {{PropertyAccessor}} which will support {{HttpParameters}}, let me work on that. > List based parameters no longer work when there is only one value. > ------------------------------------------------------------------ > > Key: WW-4702 > URL: https://issues.apache.org/jira/browse/WW-4702 > Project: Struts 2 > Issue Type: Bug > Affects Versions: 2.5.5 > Reporter: Adam Greenfield > Fix For: 2.5.6 > > > If an action has a List parameter, but is only called with one value, the parameter is never set. > Consider the basic action below. > {noformat} > public class TestAction > { > private List object; > public String execute() > { > for (SomeObject user : object) > { > System.out.println("as list" + user.field); > } > return "success"; > } > public static class SomeObject{ > private String field; > public void setField(String field) > { > this.field = field; > } > } > public List getObject() > { > return object; > } > public void setObject(List object) > { > this.object = object; > } > } > {noformat} > Performing a GET on "/test.action?object.field=a" > Expected outcome: "object" list should be populated with 1 object. with a field value of "a" > Actual Outcome: object list is empty. > Performing a GET on "/test.action?object.field=a&object.field=b" works as expected (list has 2 entries). > The following changes to [ParametersInterceptor|https://fisheye6.atlassian.com/browse/struts/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java?r=6ab6ec879cc9eb1997b88856173d2123b32509ee#to206] break this behavior. because [XWorkListPropertyAccessor|https://fisheye6.atlassian.com/browse/struts/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java?r=c7fdf7ffc5aa6744e9f3dc16c490aa0abc65f993#to138] Expects an Array of strings for value (which was previously sent when HttpParameters was a map instead of an Object). > {noformat} > if (value instanceof Parameter.File) { > newStack.setParameter(name, value.getObject()); > } else if (value.isMultiple()) { > newStack.setParameter(name, value.getMultipleValues()); > } else { > newStack.setParameter(name, value.getValue()); > } > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)