8 Replies Latest reply on Nov 8, 2006 3:10 AM by yuka shimizu

    The value of seam cannot be acquired with JSF.

    yuka shimizu Newbie

      Hello.
      I have my first simple program of ejb3 by using Seam and JSF.
      Though I tried ajax by this program
      The value acquired from the entity bean cannot be displayed as an element of JSF.
      The parameter passed by ajax in the session bean can be acquired, and DB can be accessed.
      The value of the text box doesn't change when the result is displayed after it communicates with ajax asynchronously.
      Could anyone advise,please?


      ## Environment ##
      JBOSS4.0.5GA
      jdk1.5.0_06
      jboss-seam-1.0.1.GA


      ## Register.java ##

      @Local
      public interface Register {
       public String start();
       public String confirm();
       public String register();
      
       @WebRemote
       public boolean checkExists(String username);
      
       public void destroy();
      }



      ## RegisterAction.java ##
      @Stateful
      @Name("register")
      @Scope(CONVERSATION)
      public class RegisterAction implements Register {
      
       @In(required = false)
       @Out(required=false)
       private User user;
      
       @PersistenceContext
       private EntityManager em;
      
       @Begin
       public String start(){
       user = new User();
       return "/register.jsp";
       }
      
       @Conversational(ifNotBegunOutcome = "/register.jsp")
       public String confirm(){
       return "/confirm.jsp";
       }
      
       @End
       @Conversational(ifNotBegunOutcome = "/register.jsp")
       public String register(){
       em.persist(user);
       return "/registered.jsp";
       }
      
       public boolean checkExists(String username){
       user = (User)em.createQuery("select OBJECT(o) from User o where o.username=:username").setParameter("username", username).getSingleResult();
       if(user == null) return true;
       else return false;
       }
      
       @Destroy
       @Remove
       public void destroy(){}
      }


      ## register.jsp ##

      <%@ page language="java" contentType="text/html; charset=Shift_JIS" pageEncoding="MS932"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <html><head><title>register</title></head>
      <script type="text/javascript" src="seam/remoting/resource/remote.js">
      </script>
      <script type="text/javascript" src="seam/remoting/interface.js?register">
      </script>
      <script type="text/javascript">
      <!--
      function checkExists(i) {
       s = i.value;
       Seam.Component.getInstance("register").checkExists(s, checkExistsCallback);
      }
      function checkExistsCallback(result) {
       if (result) {
      // alert("It is not registered.");
       } else {
       document.getElementById("error").innerHTML="It has already been registered.";
      // alert("It has already been registered. ");
       }
      }
      //-->
      </script>
      <body>
      <f:view>
       <h:form>
       <table border="0">
       <tr>
       <td>User ID</td>
       <td><h:inputText value="#{user.username}" required="true" onblur="javascript:checkExists(this);"/><span id="error"></span></td>
       </tr>
       <tr>
       <td>Name</td>
       <td><h:inputText value="#{user.name}" required="true" /></td>
       </tr>
       <tr>
       <td>Password</td>
       <td><h:inputSecret value="#{user.password}" required="true" /></td>
       </tr>
       </table>
       <h:messages />
       <h:commandButton type="submit" value="confirm" action="#{register.confirm}" />
       </h:form>
      </f:view>
      </body></html>



        • 1. Re: The value of seam cannot be acquired with JSF.
          johnurban Newbie

           


          The value acquired from the entity bean cannot be displayed as an element of JSF.


          Is this an error/exception you are getting? If so, post the whole stack trace of the exception.

          • 2. Re: The value of seam cannot be acquired with JSF.
            yuka shimizu Newbie

            Hello johnurban!
            Thank you for the reply.

            No error has gone out.
            Contents of the text box write and it doesn't change
            though the message of "Already that has been registered" is displayed though
            it is a program that registers ID, the name, and the password though
            I want to make the value enter the name by the automatic operation, too when the one registered in ID is input.
            The error is not displayed in the log at this time.
            Please point it out when something mistake etc. are found.

            • 3. Re: The value of seam cannot be acquired with JSF.
              Shane Bryzak Master

              Turn debug on in Seam remoting so that you can see that the request and response xml is valid.

              • 4. Re: The value of seam cannot be acquired with JSF.
                yuka shimizu Newbie

                Hello Shane Bryzak!
                Thank you for advice!


                Is "Turn debug on in Seam remoting" to be added to the property of cxml debugging as follows?
                It becomes an error though jboss-seam-debug.jar is added to the classpath, and it Deproied it.
                Are other settings necessary?
                Excuse me, may I have advice in a rudimentary question?

                <components>
                 <component name="org.jboss.seam.core.init">
                 <property name="debug">true</property>
                 <property name="myFacesLifecycleBug">true</property>
                 <property name="jndiPattern">ks/#{ejbName}/local</property>
                 </component>
                
                 <component class="org.jboss.seam.core.Ejb" installed="false"/>
                </components>



                Caused by: java.lang.NoClassDefFoundError: com/sun/facelets/compiler/Compiler
                 at java.lang.Class.getDeclaredConstructors0(Native Method)
                 at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
                 at java.lang.Class.getConstructor0(Class.java:2640)
                 at java.lang.Class.newInstance0(Class.java:321)
                 at java.lang.Class.newInstance(Class.java:303)
                 at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils
                .java:274)
                 ... 95 more


                • 5. Re: The value of seam cannot be acquired with JSF.
                  Shane Bryzak Master

                  Put this in components.xml:

                   <component name="org.jboss.seam.remoting.remotingConfig">
                   <property name="debug">true</property>
                   </component>
                  


                  • 6. Re: The value of seam cannot be acquired with JSF.
                    yuka shimizu Newbie

                    Hello Shane Bryzak!
                    Thank you for advice!

                    I tried your advice, and deploy error was able to be lost. Thank you!
                    But, the material of debugging is a little, and I cannot obtain information wanting it yet.
                    Though Seam Tutorial etc. are seen ???
                    Could you teach when there are a sample etc. that become material concerning debug or references of JSF + Seam + Ajax?

                    • 7. Re: The value of seam cannot be acquired with JSF.
                      Shane Bryzak Master

                      Besides a small section in the remoting chapter of the documentation, there's not really much else that can be said about debugging without getting overly verbose. In general, being able to see the xml request/response packets should go a long way toward solving any remoting issues. I can only suggest that having access to a good Javascript debugger is essential (I use Venkman, the Firefox one) as most issues seem to be client-side.

                      • 8. Re: The value of seam cannot be acquired with JSF.
                        yuka shimizu Newbie

                        Hello Shane Bryzak!

                        Thank you for advising to the question in my poor English for this time.
                        I will try a little more variously.
                        I wish to express my gratitude for your kindness.
                        Please continue your favors toward something when is moreover.