2 Replies Latest reply on Feb 24, 2011 6:29 AM by nigiyan

    EntityHome and Remoting

    eukreign

      I'm trying to figure out how to do the basic CRUD with a EntityHome object via Seams Remoting framework. Does anyone have any examples of how this is supposed to work? Or has anyone successfully done this and can give me some pointers of what needs to be done.

        • 1. Re: EntityHome and Remoting
          nigiyan

          Good question. I face same issue.


          I have simple SEAM plus JSF project, now I want to add ajax support with Seam.Remoting so that entity bean's values to be populated on each jsf component's onblur.
          To do this I need MyEntityBeansHome's instance accessible somehow from @Local seam component (like ManagerAction class in Seam Framework book, chapter 21.1.1) but couldn't find a way to do it.

          • 2. Re: EntityHome and Remoting
            nigiyan

            The solution is simple, just need to follow the right steps.
            In my case I have long-running conversation and want to avoid Richfaces' ajax full form submission in order to have one input element's content set to data model / instance


            MyEntityHomeEdit.xhtml


            ...
                <script type="text/javascript" src="seam/resource/remoting/resource/remote.js"/>
                <script type="text/javascript" src="seam/resource/remoting/interface.js?SEAM_COMPONENT_NAME_HERE_WHICH_HANDLES_REQUEST"/>
            
                <script type="text/javascript" language="javascript">
            
                    function req(source) {
                        Seam.Remoting.getContext().setConversationId(#{conversation.id});
                        var seamComp = Seam.Component.getInstance("SEAM_COMPONENT_NAME_HERE_WHICH_HANDLES_REQUEST");
            
                        seamComp.doSomething(source.anything, responseHandlingJSMethod);
                    }
                </script>
            
            <h:form id="formId">
                <h:inputText value="#{myEntityHome.instance.someField}" onblur="req(this)"/>
            
            ...



            My EntityHome, or can be any other seam component where my entity home is injected.



            @Name("SEAM_COMPONENT_NAME_HERE_WHICH_HANDLES_REQUEST")
            @Scope(ScopeType.CONVERSATION)
            public class MyEntityHome extends EntityHome<MyEntity> {
                public boolean doSomething(String param){
                    getInstance().setFieldContent(param);
                    return true; // can be handled in js
                }
            }