You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by SE Song <se...@gmail.com> on 2017/11/17 10:06:51 UTC

Using org.apache.isis.applib.value.DateTime on View Model (JAXB) always return Current DateTime

Dear All

On my JAXB VM I has a DateTime property as bellow

@Property(editing = Editing.ENABLED)
@Getter @Setter
public org.apache.isis.applib.value.DateTime isisDateTime;

When I click to change value on my UI, it always change my value to Current
DateTime.

I also try another types such as joda LocalDate, LocalDateTime... It still
the same.

So I create another setter to debug my code, then I see that my setter has
been called 3 times. First time it's correct value, but second and thirst
it change to current date.

My Question is, why it has been call many times? why it always change my
value?

Re: Using org.apache.isis.applib.value.DateTime on View Model (JAXB) always return Current DateTime

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Use @XmlTransient annotation on the injected service fields so that jaxb
ignores them.

This is just standard jaxb behaviour, there's nothing specific to Apache
Isis here.

On Mon, 20 Nov 2017, 08:44 SE Song, <se...@gmail.com> wrote:

> Dear Dan Haywood
>
> When I change to @XmlAccessorType(XmlAccessType.FIELD), I no longer be able
> to Inject Service on my VM any more. It's another exception as bellow
>
> Error marshalling domain object to XML, due to illegal annotations on
> domain object class
> 'domainapp.modules.request.dom.vm.leaveform.LeaveFormVM'; 1 errors
> reported:  org.apache.isis.applib.services.factory.FactoryService is an
> interface, and JAXB can't handle interfaces.
>
> If I use  @XmlAccessorType(XmlAccessType.PROPERTY)  it throw another
> exception
>
> Error marshalling domain object to XML, due to illegal annotations on
> domain object class
> 'domainapp.modules.request.dom.vm.leaveform.LeaveFormVM'; 2 errors
> reported: Class has two properties of the same name "leavingDate"; Class
> has two properties of the same name "returningDate"
>
> On Fri, Nov 17, 2017 at 5:57 PM, SE Song <se...@gmail.com> wrote:
>
> > Thank so much for your quick respond, Now I use Joda LocalDate and
> > annotation. It work for now
> >
> > On Fri, Nov 17, 2017 at 5:09 PM, Dan Haywood <
> dan@haywood-associates.co.uk
> > > wrote:
> >
> >> take a look at
> >> http://isis.apache.org/guides/ugfun/ugfun.html#_ugfun_progra
> >> mming-model_view-models_jaxb_joda-datatypes
> >>
> >>
> >> On Fri, 17 Nov 2017 at 10:07 SE Song <se...@gmail.com> wrote:
> >>
> >> > Dear All
> >> >
> >> > On my JAXB VM I has a DateTime property as bellow
> >> >
> >> > @Property(editing = Editing.ENABLED)
> >> > @Getter @Setter
> >> > public org.apache.isis.applib.value.DateTime isisDateTime;
> >> >
> >> > When I click to change value on my UI, it always change my value to
> >> Current
> >> > DateTime.
> >> >
> >> > I also try another types such as joda LocalDate, LocalDateTime... It
> >> still
> >> > the same.
> >> >
> >> > So I create another setter to debug my code, then I see that my setter
> >> has
> >> > been called 3 times. First time it's correct value, but second and
> >> thirst
> >> > it change to current date.
> >> >
> >> > My Question is, why it has been call many times? why it always change
> my
> >> > value?
> >> >
> >>
> >
> >
>

Re: Using org.apache.isis.applib.value.DateTime on View Model (JAXB) always return Current DateTime

Posted by SE Song <se...@gmail.com>.
Dear Dan Haywood

When I change to @XmlAccessorType(XmlAccessType.FIELD), I no longer be able
to Inject Service on my VM any more. It's another exception as bellow

Error marshalling domain object to XML, due to illegal annotations on
domain object class
'domainapp.modules.request.dom.vm.leaveform.LeaveFormVM'; 1 errors
reported:  org.apache.isis.applib.services.factory.FactoryService is an
interface, and JAXB can't handle interfaces.

If I use  @XmlAccessorType(XmlAccessType.PROPERTY)  it throw another
exception

Error marshalling domain object to XML, due to illegal annotations on
domain object class
'domainapp.modules.request.dom.vm.leaveform.LeaveFormVM'; 2 errors
reported: Class has two properties of the same name "leavingDate"; Class
has two properties of the same name "returningDate"

On Fri, Nov 17, 2017 at 5:57 PM, SE Song <se...@gmail.com> wrote:

> Thank so much for your quick respond, Now I use Joda LocalDate and
> annotation. It work for now
>
> On Fri, Nov 17, 2017 at 5:09 PM, Dan Haywood <dan@haywood-associates.co.uk
> > wrote:
>
>> take a look at
>> http://isis.apache.org/guides/ugfun/ugfun.html#_ugfun_progra
>> mming-model_view-models_jaxb_joda-datatypes
>>
>>
>> On Fri, 17 Nov 2017 at 10:07 SE Song <se...@gmail.com> wrote:
>>
>> > Dear All
>> >
>> > On my JAXB VM I has a DateTime property as bellow
>> >
>> > @Property(editing = Editing.ENABLED)
>> > @Getter @Setter
>> > public org.apache.isis.applib.value.DateTime isisDateTime;
>> >
>> > When I click to change value on my UI, it always change my value to
>> Current
>> > DateTime.
>> >
>> > I also try another types such as joda LocalDate, LocalDateTime... It
>> still
>> > the same.
>> >
>> > So I create another setter to debug my code, then I see that my setter
>> has
>> > been called 3 times. First time it's correct value, but second and
>> thirst
>> > it change to current date.
>> >
>> > My Question is, why it has been call many times? why it always change my
>> > value?
>> >
>>
>
>

Re: Using org.apache.isis.applib.value.DateTime on View Model (JAXB) always return Current DateTime

Posted by SE Song <se...@gmail.com>.
Thank so much for your quick respond, Now I use Joda LocalDate and
annotation. It work for now

On Fri, Nov 17, 2017 at 5:09 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> take a look at
> http://isis.apache.org/guides/ugfun/ugfun.html#_ugfun_
> programming-model_view-models_jaxb_joda-datatypes
>
>
> On Fri, 17 Nov 2017 at 10:07 SE Song <se...@gmail.com> wrote:
>
> > Dear All
> >
> > On my JAXB VM I has a DateTime property as bellow
> >
> > @Property(editing = Editing.ENABLED)
> > @Getter @Setter
> > public org.apache.isis.applib.value.DateTime isisDateTime;
> >
> > When I click to change value on my UI, it always change my value to
> Current
> > DateTime.
> >
> > I also try another types such as joda LocalDate, LocalDateTime... It
> still
> > the same.
> >
> > So I create another setter to debug my code, then I see that my setter
> has
> > been called 3 times. First time it's correct value, but second and thirst
> > it change to current date.
> >
> > My Question is, why it has been call many times? why it always change my
> > value?
> >
>

Re: Using org.apache.isis.applib.value.DateTime on View Model (JAXB) always return Current DateTime

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
take a look at
http://isis.apache.org/guides/ugfun/ugfun.html#_ugfun_programming-model_view-models_jaxb_joda-datatypes


On Fri, 17 Nov 2017 at 10:07 SE Song <se...@gmail.com> wrote:

> Dear All
>
> On my JAXB VM I has a DateTime property as bellow
>
> @Property(editing = Editing.ENABLED)
> @Getter @Setter
> public org.apache.isis.applib.value.DateTime isisDateTime;
>
> When I click to change value on my UI, it always change my value to Current
> DateTime.
>
> I also try another types such as joda LocalDate, LocalDateTime... It still
> the same.
>
> So I create another setter to debug my code, then I see that my setter has
> been called 3 times. First time it's correct value, but second and thirst
> it change to current date.
>
> My Question is, why it has been call many times? why it always change my
> value?
>