struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlos Luis Zúñiga Sibaja" <carlosluiszun...@gmail.com>
Subject Re: Struts 2.1.2 type conversion failing for Integer method.
Date Thu, 13 Nov 2008 20:46:26 GMT
Adam,

For what I know the only solution to this problem is upgrading the version
of OGNL included in struts, but there are problems by doing that (check out
the JIRA issue). So the workaround for me was to stop using generic
properties in my Model objects.

Please, if somebody has come across a similar issue, feel free to chime in.


  Carlos Luis Zúñiga Sibaja
__________________________
  carlosluiszuniga@gmail.com

  divide et impera...


On Thu, Nov 13, 2008 at 2:33 PM, Adam Ruggles <a.ruggles@gmail.com> wrote:

>
> Are there any workarounds for this?  I've tried using a conversion
> properties
> file for my action and adding the following:
> id=example.MyTypeConverter
>
> but it didn't get called from struts.  I wonder if it's because it should
> be
> model.id or myobject.id.
>
>
> Carlos Luis Zúñiga Sibaja wrote:
> >
> > Actually, this is a problem in OGNL, because the version bundled with
> > Struts
> > 2.1.2 cannot handle objects with generifyed properties. This definitively
> > sucks since it prevents a lot of code reuse, in my specific experience I
> > had
> > a similar implementation for a base ModelObject and an AbstractCrudAction
> > but because of this error, it is not possible to generify these objects.
> >
> > There is already a Jira issue about this situation:
> > https://issues.apache.org/struts/browse/WW-2128
> >
> > Regards,
> >
> >   Carlos Luis Zúñiga Sibaja
> > __________________________
> >   carlosluiszuniga@gmail.com
> >
> >   divide et impera...
> >
> >
> > On Wed, Nov 12, 2008 at 11:31 PM, Adam Ruggles <a.ruggles@gmail.com>
> > wrote:
> >
> >>
> >> I'm trying to figure out why struts/xwork is having issues doing the
> >> conversion on an Integer property.  Here is the configuration.
> >>
> >> public class MyAction extends ActionSupport implements Preparable,
> >> ModelDriven<MyObject> {
> >>  private MyObject obj;
> >>  public void prepare() throws Exception {
> >>    obj = new MyObject();
> >>  }
> >>  public MyObject getModel() {
> >>    return obj;
> >>  }
> >>  public String execute() {
> >>    // MyObject.id is not set, although ever other field is fine.
> >>  }
> >> }
> >>
> >> public interface CoreEntity<ID extends Serializable> {
> >>  ID getId();
> >>  void setId(ID id);
> >> }
> >>
> >> public class MyObject implements CoreEntity<Integer> {
> >>  private String description;
> >>  private Integer id;
> >>
> >>  public Integer getId() {
> >>    return id;
> >>  }
> >>  public void setId(final Integer id) {
> >>    this.id = id;
> >>  }
> >>  public String getDescription() {
> >>    return description;
> >>  }
> >>  public void setDescription(final String description) {
> >>    this.description = description;
> >>  }
> >> }
> >>
> >> The error I'm getting is
> >> ognl.MethodFailedException: Method "setId" failed for object
> >> example.MyObject@6d9bf996[description=Test Category 2,id=<null>]
> >> [java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to
> >> java.lang.Integer]
> >>
> >> It looks like it's having an issue with my use of generics in the
> >> interface,
> >> but I don't know for sure.  Is there any way for me to tell
> struts2/xwork
> >> that the id field for the model object is a Integer?
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Struts-2.1.2-type-conversion-failing-for-Integer-method.-tp20475044p20475044.html
> >> Sent from the Struts - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Struts-2.1.2-type-conversion-failing-for-Integer-method.-tp20475044p20489006.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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