Based on the suggestions I got after my last mail, I am now in the
process of implementing a View Model. 
I'm basing my implementation on the ViewModels in isis-app-todoapp, and
the YouTube videos about View Models. 

So far I've been able to create a View Model that shows a list of
objects, but ran into a problem when trying to add a Filter
functionality. It's probably due to a misunderstanding on how ViewModels
work, so I'd like to make sure my approach is correct. 

I created a DTO that stores the fields I want to use as a filter, and
annotated it with JAXB XML annotations (I think this is necessary due to
the ViewModels using a String representation at some point). 

Then I created an attribute in the ViewModel of type DTO, and created an
action "Filter" that asks the user for values for the DTO's fields and
stores them in the ViewModel's attribute, and then returns "this". 

The problem appears when the getObjects method is called after reloading
the page. I try to access the attribute of type DTO and get the values
that "Filter" set, to show the list with only the values that meet the
criteria, but at this point all the DTO's fields are null. 

TodoApp's ToDoItemsByDateRangeViewModel.java has a DateRange attribute,
which leads me to think that ViewModels can store objects as attributes
and use their values for processing, but in my case it seems that my
FilterDTO is not being stored between action invocations. 

The DTO is initialized in the ViewModels constructor, so I'm wondering
if after returning "this" from an action, the object is recreated at
some point? 

Or maybe I'm not doing this correctly, or ViewModels are stateless,
maybe when dealing with non persistent objects? 

Thank you.

-- 
Hector Fabio Meza

R&D LEAD SMARTOOLS 
(57) 300 2254455= [1] 
Skype: hectorf.meza 
www.smartools.com.co [2] 

 

Links:
------
[1] tel:%2857%29%20300%206815404
[2] http://www.smartools.com.co/

Reply via email to