Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 59684F44D for ; Thu, 30 May 2013 09:43:49 +0000 (UTC) Received: (qmail 29132 invoked by uid 500); 30 May 2013 09:43:47 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 28573 invoked by uid 500); 30 May 2013 09:43:37 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 28501 invoked by uid 99); 30 May 2013 09:43:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 May 2013 09:43:35 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: local policy) Received: from [212.113.174.24] (HELO mx.netcabo.pt) (212.113.174.24) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 May 2013 09:43:29 +0000 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=Yc8Ct49lKhYLd5XaLBq3K/0HTegjVa4igHzx7/CssdY= c=1 sm=2 a=8rr0XhBuKLMA:10 a=wPDyFdB5xvgA:10 a=mV9VRH-2AAAA:8 a=NJ9caWlXaTqm-SLyOr8A:9 a=QEXdDO2ut3YA:10 a=tFKAoNRVxATjn7hi:21 a=c5RBPandRCcRksgo:21 a=PqLFr7uXLZW32UnFLk0A:9 a=_W_S_7VecoQA:10 a=NLIP1ajpVx_Gd8mR:21 a=5julPMPNKAfz0tAi:21 a=4yT0rvclcHs_ZVuf:21 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUPALEdp1FehB5l/2dsb2JhbABZgwkwAYM6sGGJVoMRgQMEAXoXdIIbCAEBBAEjKwgoCwsYKgICMQgeDgcEARwEhVWCEQqnXZIZjWEVEoESgkMOgQYDmGSEdYsigxBtgQM X-IPAS-Result: ArUPALEdp1FehB5l/2dsb2JhbABZgwkwAYM6sGGJVoMRgQMEAXoXdIIbCAEBBAEjKwgoCwsYKgICMQgeDgcEARwEhVWCEQqnXZIZjWEVEoESgkMOgQYDmGSEdYsigxBtgQM Received: from a94-132-30-101.cpe.netcabo.pt (HELO mail.almeida.at) ([94.132.30.101]) by neti06smtpa.hdi.tvcabo with ESMTP; 30 May 2013 10:42:45 +0100 Received: from localhost (localhost [127.0.0.1]) by mail.almeida.at (Postfix) with ESMTP id BA3FE20BA5 for ; Thu, 30 May 2013 10:42:44 +0100 (WEST) X-Virus-Scanned: Debian amavisd-new at almeida.at Received: from mail.almeida.at ([127.0.0.1]) by localhost (mail.almeida.at [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RdNqm-t3JB4A for ; Thu, 30 May 2013 10:42:41 +0100 (WEST) Received: from [192.168.10.111] (webservices.itclinical.com [195.23.251.147]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: miguel) by mail.almeida.at (Postfix) with ESMTPSA id A207D203BA for ; Thu, 30 May 2013 10:42:41 +0100 (WEST) Message-ID: <1369906950.2648.15.camel@itcd001> Subject: Re: How to set the name parameter on a multiple s:select From: Miguel Almeida To: user@struts.apache.org Date: Thu, 30 May 2013 10:42:30 +0100 In-Reply-To: References: <1369823255.4995.13.camel@itcd001> Content-Type: multipart/alternative; boundary="=-HTSOXmN8nEOG701UfVi4" X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --=-HTSOXmN8nEOG701UfVi4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Thanks for the feedback Dale. A couple of thoughts below. On Wed, 2013-05-29 at 08:18 -0400, Dale Newfield wrote: > I would have a setter on my action class that takes an array of ids. Then the action does the appropriate lookups, and sets the hydrated objects on the appropriate models. That's an alternative, yes. I do tend to prefer having the model objects in my actions though, to keep the number of objects to a minimum - it makes more sense to have a List objects than an Integer[] ids, but maybe that's personal preference. > You do recognize that the data you provided is ambiguous, though, right? Nothing you stated is sufficient to know *which* entity2 objects should be set on entity, just which entity3 objects you want those entity2 objects to have. In fact, if you don't happen to get a number of entity3 ids that matches the number of entity2s on entity, you've left yourself no way of knowing how to proceed. (Remember, all you get is a (potentially unordered) list of ids from the form submission, not tuples.) I'm not sure where the ambiguity is. Take the following request parameters: entity.entity2List[0].entity3.id=10 entity.entity2List[1].entity3.id=20 There is no ambiguity in how the Object should be populated - one entity, which has two Entity2 on the entity2List object: the first entity2 has an Entity3.id=10 and the second Entity2 has an Entity3.id=20. In fact, this request works as expected (as evidenced by the test case [1]). The challenge is to create an s:select that generates that request parameters! Miguel [1] Unit Test snippet request.setParameter("entity.entity2List[0].entity3.id", "2"); request.setParameter("entity.entity2List[1].entity3.id", "11"); createAction("/example/Conversion.action"); executeProxy(); Entity entity = ((TypeConversionAction) action).getEntity(); assertNotNull(entity); assertNotNull(entity.getEntity2List()); assertEquals(2, entity.getEntity2List().size()); assertEquals(2, entity.getEntity2List().get(0).getEntity3().getId()); assertEquals(11, entity.getEntity2List().get(1).getEntity3().getId()); > > -Dale > > On May 29, 2013, at 6:27 AM, Miguel Almeida wrote: > > > Dear all, > > > > Imagine you have the following scenario: > > - a property in your action: private Entity entity; > > > > - Entity has a List entity2List > > - Entity2 has a Entity3 entity3 > > > > Now, you need an s:select with multiple="true" to populate entity3. This > > corresponds to having a request in the form > > entity.entity2List[n].entity3.id (n=0,1,2...depending on how many items > > are selected). > > > > Question: how should the name parameter of the s:select be like to > > achieve this? > > > > Me and Lukasz have tried the following without success (meaning > > entity.entity2List has is empty): > > > name="%{entity.entity2List[].entity3.id}" list="#someList" listKey="id" > > listValue="code"/> > > > name="entity.entity2List[].entity3.id" list="#someList" listKey="id" > > listValue="code"/> > > > > > > Thank you for your help! > > > > Miguel Almeida > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > --=-HTSOXmN8nEOG701UfVi4--