Execute a Seam component

Hello,

I try to execute the “deleteActions” component from within a class extending “AbstractWork” like this :

return (DeleteActions) SeamComponentCallHelper.getSeamComponentByName("deleteActions");

But this throw the exception bellow :

java.lang.IllegalStateException: No application context active
    at org.jboss.seam.Component.forName(Component.java:1902)
    at org.nuxeo.ecm.platform.ui.web.util.SeamComponentCallHelper.getSeamComponentByName(SeamComponentCallHelper.java:73)

I try the code below to activate the application context, without success:

Contexts.getApplicationContext();

Is it the good way to call a seam component ?

Thank you.

0 votes

1 answers

3259 views

ANSWER



Hi,

You should not try to use a Seam component outside of an active Seam context, as mentioned in the logs. An active Seam context could be: inside another Seam component (in which you could inject deleteActions with @In), in a facelet (XHTML) within an EL expression or in any place where EL expressions are allowed.

In your case you might want to directly use some API called by the Seam component, for instance TrashService.

1 votes



TrashService works here. Thank you.
01/24/2014