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

      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 ##

      ## Register.java ##

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

      ## RegisterAction.java ##
      public class RegisterAction implements Register {
       @In(required = false)
       private User user;
       private EntityManager em;
       public String start(){
       user = new User();
       return "/register.jsp";
       @Conversational(ifNotBegunOutcome = "/register.jsp")
       public String confirm(){
       return "/confirm.jsp";
       @Conversational(ifNotBegunOutcome = "/register.jsp")
       public String register(){
       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;
       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"%>
      <script type="text/javascript" src="seam/remoting/resource/remote.js">
      <script type="text/javascript" src="seam/remoting/interface.js?register">
      <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. ");
       <table border="0">
       <td>User ID</td>
       <td><h:inputText value="#{user.username}" required="true" onblur="javascript:checkExists(this);"/><span id="error"></span></td>
       <td><h:inputText value="#{user.name}" required="true" /></td>
       <td><h:inputSecret value="#{user.password}" required="true" /></td>
       <h:messages />
       <h:commandButton type="submit" value="confirm" action="#{register.confirm}" />