Hi, On Mon, Dec 8, 2014 at 8:41 AM, Dan Haywood <[email protected]> wrote:
> On 7 December 2014 at 11:19, GESCONSULTOR - Óscar Bou < > [email protected]> wrote: > > > Hi to all. > > > > Is there a way to hide an object service programmatically (i.e., using a > > hide() method) ? > > > > The only way I know is the @Hidden annotation. > > > > > There isn't currently any built-in method for this, no. You can find this > out by looking for facets that implement HidingInteractionAdvisor. > > But on way the requirement can be supported is using the event bus, eg > adding this to the SimpleObjects service will hide the service (because all > of its actions are hidden): > > > @Programmatic > @PostConstruct > public void postConstruct() { > eventBusService.register(this); > } > > @Programmatic > @Subscribe > public void on(final ActionInteractionEvent<?> ev) { > switch(ev.getPhase()) { > case HIDE: > > if(SimpleObjects.class.isAssignableFrom(ev.getSource().getClass())) { > ev.hide(); > } > break; > } > } > > @javax.inject.Inject > private EventBusService eventBusService; > > > > Given we have such flexible support, I'm not certain we need any additional > special supporting methods. What do you think? > I believe another user recently asked about the same functionality. Or at least I understood his/her question to be the same ... Anyway, I think the code above is indeed very flexible and useful, and we have to add it to our documentation. I haven't read any docu about EventBusService yet, but I haven't seen anything like this in the hide/disable/validate related pages. I'll add this example to the documentation in the next days unless someone does it before me. > > HTH > Dan > > > > > > Same way, both them could be disabled (on Services it would mean all > > actions would be disabled). > > > > And also, for objects they could be programmatically validated. > > > > It could be also useful for per-instance security. > > > > > > Is it currently available? > > If not, could it be a good idea to create a facet for hide(), disable(), > > validate() methods ? > > > > > Thanks, > > > > Oscar > > > > > > > > >
