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 13674E3EC for ; Mon, 3 Dec 2012 17:05:54 +0000 (UTC) Received: (qmail 27319 invoked by uid 500); 3 Dec 2012 17:05:52 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 26823 invoked by uid 500); 3 Dec 2012 17:05:51 -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 26794 invoked by uid 99); 3 Dec 2012 17:05:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Dec 2012 17:05:50 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.214.176] (HELO mail-ob0-f176.google.com) (209.85.214.176) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Dec 2012 17:05:45 +0000 Received: by mail-ob0-f176.google.com with SMTP id un3so3067719obb.35 for ; Mon, 03 Dec 2012 09:05:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=1kqypT65qJdw3i/uMPm+nMarRNry8M2Tli6+E5ciF1E=; b=mv7Qhv+JA27lc6ocPiKgEdZp3MPRxxu9Q2ZGBT65QncpPt7jFf9du+U8s2s3KrtntP mby8b/6C7f1DkROiQ51LCTkFmJhKo+Z52qAv8C42nMwK/OP7u1uDNzSCNNq3NzbKvqq+ N3l95gg5hMNffk0f38vM6qrKpjCObX7vx+cQp18SXw9ZQdQzJu7iVLfnvlItFWNf74ni z3eZ+sBb62fBKML/dChqi4fa22E2v9+ALeBRVVVl4owNvyxqBrTOiXaHw1hanvmfH1Fb MgQXKO8T8jJNngJzDVXio8n8j8o02fMPNVBhMVqEfxXh+YKQGW95KD31AekiQp6d7qHf 76vA== Received: by 10.60.20.101 with SMTP id m5mr8606241oee.102.1354554323930; Mon, 03 Dec 2012 09:05:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.9.202 with HTTP; Mon, 3 Dec 2012 09:05:03 -0800 (PST) In-Reply-To: References: From: Eric Lentz Date: Mon, 3 Dec 2012 12:05:03 -0500 Message-ID: Subject: Re: Extending base class and accessing implementation's fields in Struts 2 To: Struts Users Mailing List Content-Type: multipart/alternative; boundary=e89a8fb1f6004e8d9b04cff5c1ff X-Gm-Message-State: ALoCoQlx/ITbm6tlSRgHw8w/Ppwgyu4OGirRKqyww0UlG89qATlrM9qjEG8pSzErdAvqIiJv4hF6 X-Virus-Checked: Checked by ClamAV on apache.org --e89a8fb1f6004e8d9b04cff5c1ff Content-Type: text/plain; charset=ISO-8859-1 I'm almost there. I didn't suspect that it would work that way with the iterator. Should have tried it first! Thanks Dave. On the way back, such as in a post, if BaseObject is an interface or abstract, as I'm hoping for it to be, then Struts tries to instantiate the BaseObject type, which it can't, so it throws: [com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler] Could not create and/or set value back on to object java.lang.InstantiationException at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30) at java.lang.reflect.Constructor.newInstance(Constructor.java:501) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:130) at com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.createObject(InstantiatingNullHandler.java:159) at com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.nullPropertyValue(InstantiatingNullHandler.java:137) at com.opensymphony.xwork2.ognl.OgnlNullHandlerWrapper.nullPropertyValue(OgnlNullHandlerWrapper.java:21) at ognl.ASTProperty.getValueBody(ASTProperty.java:118) ...etc. Any ideas on solving that? - Eric On Mon, Dec 3, 2012 at 11:19 AM, Eric Lentz wrote: > I have > List foo > > The list is of type BaseObjectImpl > > BaseObject has fields: > String a > String b > > BaseObjectImpl has fields: > String c > String d > > Now I'm in a JSP and want to iterate foo (using ), accessing > fields c and d (inside iterator using , for example). How? As > far as Struts knows I'm dealing with BaseObject. Is there a way for me to > cast to BaseObjectImpl without creating a StrutsTypeConverter for every > object I'm extending? In my use case, there will be several and the > temptation is to just define the list with the implementation which foils > reusability patterns (e.g., List). > > Likewise, what to do when posting back to a field like this: > BaseObject bar (which has BaseObjectImpl as its implementation) e.g., > > > > Is there a totally different approach that would be better or is > StrutsTypeConverter the only good answer? > > - Eric > > --e89a8fb1f6004e8d9b04cff5c1ff--