[forge-issues] [JBoss JIRA] (FORGE-617) Cannot access Stateful EJB from inner anonymous class

Luca Masini (JIRA) jira-events at lists.jboss.org
Wed Aug 8 17:57:06 EDT 2012


    [ https://issues.jboss.org/browse/FORGE-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12710591#comment-12710591 ] 

Luca Masini commented on FORGE-617:
-----------------------------------

My fault, I never updated this issue with the comments on the forge-dev mailing list.

With Richard we've done some experiments, because he thinks (and I'm with him) that things must be done in a simple way without using strange tricks or utility classes.

We tried with FacesConverter but he noticed that a weird bug that will be fixed in JSF 2.2 doesn't allow us to have a global converter for every domain object.

Then we tried with a ManagedBean and an injected EntityManager, but also this way we was not in the right direction, principally because the injected EM is not the EXTENED one linked to the SFSB.

At this point we think that a good solution can be to have a findById method inside the EJB (may be we can modify the retrieve method for that) and use the Session Context to call the right bean.

In almost-pseudo code:

    @Resource
    SessionContext sessionContext;
    public Converter getConverter() {

        final GroupBean ejbProxy = sessionContext.getBusinessObject(GroupBean.class);

        return new Converter() {
            @Override
            public Object getAsObject(FacesContext context, UIComponent component, String value) {

                return ejbProxy.findById(Long.valueOf(value));
            }

            @Override
            public String getAsString(FacesContext context, UIComponent component, Object value) {
                if (value == null)
                {
                    return "";
                }

                return String.valueOf(((Group) value).getId());
            }
        };
    }

What do you think ??
                
> Cannot access Stateful EJB from inner anonymous class
> -----------------------------------------------------
>
>                 Key: FORGE-617
>                 URL: https://issues.jboss.org/browse/FORGE-617
>             Project: Forge
>          Issue Type: Bug
>          Components: Scaffold
>            Reporter: Luca Masini
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the forge-issues mailing list