0

first to all this new thread is related to this one: Updating certain view programmatically from a JMS listener class Now, additional to this lack of server-push feature, I have other problem with a simple calculated property which I have in the same transient module view. Here is one version (I have tried several ways) for my transient view:

@View(members="Counter [counter], readItems")
public class TrackIt {

    @OneToMany
    @ReadOnly
    @OnSelectElementAction("TrackIt.checkSelectedReadItems")
    private Collection<ReadItem> readItems;

    public int getCounter() {
        return readItems!=null?readItems.size():0;
    }

    public Collection<ReadItem> getReadItems() {
        return readItems;
    }

    public void setReadItems(Collection<ReadItem> readItems) {
        this.readItems = readItems;
    }

}

So, the ReamItem is the entity where I'm persisting the received objects by the JMS listener. So, as I'm using simple manual refresh of the view, I was hoping to see the result of the calculated counter property at first and also after each manual refresh, but I'm not getting any value for this property just a blank and empty space after the Counter label (btw, the collection is showed fine). I have tried going into the DB with the persistent manager and getting the counter from the ReadItem entity directly into the calculated property but did not work, I also tried using a Default Value Calculator and it no works. But the funniest thing here is that I changed the getCounter() to only return a simple int like 100, but it does not work too.

So, any tips on this calculated property into a transient view could be nice.

Thanks in advance,

Community
  • 1
  • 1
HayrolR
  • 761
  • 5
  • 9

1 Answers1

0

Possibly it's related with the way you fill the view. Please put the code you're using to fill the view.

javierpaniza
  • 677
  • 4
  • 10
  • I'm not doing anything else to populate the view ... just the class with @View and declaring the controller and the module as a detail only view without CRUD and so on. – HayrolR Jan 02 '13 at 20:10
  • Now, I realized that only the collection are showed correctly... but nothing is accessible at first just in the moment that the view is rendered for the collection. I tried persisting the counter (into the JMS listener) using a small entity and accessing that as a reference in my transient view, but the only field available to be showed is the Id of the small entity, which only has two properties (the id and the counter), then I decided to use an action with on-each-request="true" in the controller: – HayrolR Jan 02 '13 at 20:26
  • `public class UpdateReadItemsCountAction extends ViewBaseAction // To use getView() { public void execute() throws Exception { super.executeAfter(); ReadItemCount readItemCount = XPersistence.getManager().find(ReadItemCount.class, "402881c33bc3cb08013bc3cc1e8d0000"); if (getView().getModelName().equalsIgnoreCase("TrackIt")) { getView().getSubview("readItemCount").setModel(readItemCount); getView().getSubview("readItemCount").refresh(); } super.executeBefore(); } }` – HayrolR Jan 02 '13 at 20:28
  • Try to set the value directly in the view: `getView().setValue("readItemCount", readItemCount.getValue())` – javierpaniza Jan 07 '13 at 12:47
  • where count is a regular property (with setter) of TrackIt. – javierpaniza Jan 07 '13 at 12:53