📄 userlistaction.java
字号:
/*
* $Id: TypeAction.java 54929 2004-10-16 16:38:42Z germuska $
*
* Copyright 2000-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sample.controller.action;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;
import wsClient.UserAccountDTO;
import com.sample.model.service.imp.UserAccountMgrImp;
/**
* Implementation of <strong>Action</strong> that validates a different 'types'.
*
*/
public final class UserListAction extends Action {
/**
* Commons Logging instance.
*/
private Log log = LogFactory.getFactory().getInstance(this.getClass().getName());
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
System.out.println(" user list action ..........");
HttpSession session = request.getSession();
//session.setAttribute("loginName",loginForm.getLoginName());
System.out.println("loginName>>>>"+session.getAttribute("loginName")+"****");
UserAccountMgrImp userAccountMgr = new UserAccountMgrImp();
ArrayList userList = (ArrayList) userAccountMgr.getUserList();
DynaValidatorForm userListForm = (DynaValidatorForm) form;
// userListForm.set("name",new String[2]);
// userListForm.set("loginName",new String[2]);
//
// for (int i=0; i<2; i++) {
// String name1 = "name"+i;
// String loginName1 = "loginname"+i;
//
// userListForm.set("name",i,name1);
// userListForm.set("loginName",i,loginName1);
//
//
// }
userListForm.set("name",new String[userList.size()]);
userListForm.set("loginName",new String[userList.size()]);
userListForm.set("password",new String[userList.size()]);
userListForm.set("email",new String[userList.size()]);
userListForm.set("phone",new String[userList.size()]);
userListForm.set("userAccountID",new String[userList.size()]);
userListForm.set("registrationFee",new String[userList.size()]);
for (int i=0; i<userList.size(); i++) {
UserAccountDTO userAccountDTO = (UserAccountDTO) userList.get(i);
userListForm.set("name",i,userAccountDTO.getName());
userListForm.set("loginName",i,userAccountDTO.getLoginName());
userListForm.set("password",i,userAccountDTO.getPassword());
userListForm.set("email",i,userAccountDTO.getEmail());
userListForm.set("phone",i,userAccountDTO.getPhone());
userListForm.set("userAccountID",i,userAccountDTO.getUserAccountID().toString());
userListForm.set("registrationFee",i,userAccountDTO.getRegistrationFee().toString());
}
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -