#266 setValue() On Hidden Properties

v4.6
open
nobody
None
5
2012-11-26
2012-10-26
pigbar
No

In some cases will be useful to allow setValue on View for Hidden properties.
The Hidden properties are allowed for Search actions, but not for SetValues on it.

Discussion

  • Javier Paniza
    Javier Paniza
    2012-10-29

    You cannot do a setValue on a hidden property because the hidden properties are not in the view. I think that you're confunding the hidden concept from HTML and the @Hidden concept from OpenXava. In HTML is a value in the form that exists but is not visible, while in OpenXava and @Hidden says to OpenXava that is a property for internal programmer of the developer with no meaning for the user, so when OX generates automatic views or tabs it does not include it. However, you can include a @Hidden property in a view or tab if you add it explicitly.
    And you cannot set properties that are not in the View. I think you're trying to use web development techniques to OpenXava, but remember that OX has a high level of abstraction (in fact in it first incarnations it was a Swing application generators).
    Most use cases that requires a hidden in html can be solved in OX with session objects with @Inject.
    What concret problem are you trying to solve?

     
  • pigbar
    pigbar
    2012-10-29

    Hi Javier,
    I am not missunderstanding the concept, as you say a Hidden property has meaning for the developer, well, as developer i would like to get access for a hidden property of the model, remember that you can use such hidden properties in search conditions, an also there not in the vew either.

    I had a view, with all its members readonly, but not a collection. When the user add a item to the collection i do get the total, summary, for a porpertie.
    At the model, at a prepersist or preupdate method i try to set a value for a propertie from the model, but as all the properties at the view were readonly OX doesn't not throw any prepersist neither preupdate method.
    There are other cases where can acces the hidden properties from the view colud be useful.

    Regards

     
  • Javier Paniza
    Javier Paniza
    2012-10-30

    Hi Bladimir,

    > as developer i would like to get access for a hidden property of the model
    Yes, you can. Just access to the model object using getView().getEntity() and from the model you can access to any propery you want. However, you cannot do a getView().getValue("aPropertyNotInTheView") because the view object only store the displayed data. We cannot store in the view object all the possible data of the model because it can be in some case almost the complete database, imagine a model central to your domain design with many references and collections.

    > I had a view, with all its members
    I think your case can be solved touching something in the model and maybe refreshing the view, but I need more details and see some code. Please, put your case in the help forum with some revelant chunks of code, and we can figure an [elegant] way to solve it.