0

我正在使用 jsf1.2 进行接缝工作。

一切对我来说都很好,除了搜索操作。谁能建议我以正确的方式走?

在这里,我如何拥有我的表格:

            <h:form class="input-list" id="searchUser" style="width:100%;"
            name="searchUser">
                    <div class="edit-label">FIRST NAME :</div>
                <h:inputText tabindex="1" id="firstName" type="text" class="miniusername clp"
                value="#{userListAction.firstName}" required="true">
                <f:validateLength minimum="3" maximum="20" />
            </h:inputText>

            <h:commandButton value="Search" tabindex="2" style="margin-left: 5px"
                action="#{userListAction.retrieveName}" class="usersearch">
            </h:commandButton>
        </h:form>

我的界面:

    @Local
    public interface UserListAction extends Serializable {

        public List<User> retrieveCustomers();

        public List<User> retrieveEmployees();

        public List<User> getUsersList();

        public CLRPUser getLoginUser();

        public List<User> retrieveName();

        @WebRemote
        public String deleteById(Integer userId);

        @WebRemote
        public CLRPUser getUserById(Integer userId);

        public UserTypeEnum getUserType();

        public void setUserType(UserTypeEnum userType);

        public void setFirstName(String firstName);

        public String getFirstName();

        public CLRPUser getCurrentUser();

        public void setCurrentUser(CLRPUser currentUser);

    }

实现接口的动作类:

    @Name("userListAction")
    @Stateless
    @AutoCreate
    public class UserListActionImpl implements UserListAction {

        @In
        protected UserService userService;

        @Out(value = "userType", scope = ScopeType.CONVERSATION, required = false)
        private UserTypeEnum userType;

        @In
        private LoggedInUser loggedInUser;

        @Out(value = "currentUser", scope = ScopeType.CONVERSATION, required = false)
        @In(value = "currentUser", scope = ScopeType.CONVERSATION, required = false)
        private CLRPUser currentUser;   

        @In(value = "firstName", scope = ScopeType.CONVERSATION, required = false)
        private String firstName;

        /**
         * 
         */

        private static final long serialVersionUID = 8649412602585430272L;

        /*
         * (non-Javadoc)
         * 
         * @see com.ermms.clrp.user.UserAction#getUsersList()
         */


        public List<User> retrieveName() {
            System.out.print("FirstName is :" + firstName);
            return userService.getAllUsers(firstName);
        }


        public UserTypeEnum getUserType() {
            return this.userType;
        }

        public void setUserType(UserTypeEnum userType) {
            this.userType = userType;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getFirstName() {
            return firstName;
        }

        @Override
        public CLRPUser getCurrentUser() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public void setCurrentUser(CLRPUser currentUser) {
            // TODO Auto-generated method stub

        }
    }

控制台说名字是:null。

我尝试了更多次,但对此我失去了理智。请给我建议。

4

1 回答 1

2

为什么要firstNameuserListAction-component 中注入?这应该从哪里来?如果没有更多,我想它的工作原理如下:

  1. 用户输入名字并单击命令按钮
  2. 表单被提交,输入的名字使用 setter-method 设置到模型中
  3. 当执行命令按钮动作时,Seam-bijection 发生并注入firstName存储在“某些”上下文中的值。由于它没有在任何地方定义,null因此被注入。

因此,如果您需要注入(对于任何情况),您应该在比赛中的任何地方输入正确的值。如果没有,只需删除@In注释。

于 2013-10-04T12:21:40.920 回答