1 package com.mlw.fps.view.taglib;
2
3 import javax.servlet.jsp.JspException;
4
5 import org.apache.struts.util.RequestUtils;
6 import org.apache.struts.util.ResponseUtils;
7
8 import com.mlw.fps.model.business.bean.SystemProperties;
9 import com.mlw.fps.model.business.dao.DAOFactory;
10 import com.mlw.fps.model.business.dao.PlayerDAO;
11 import com.mlw.fps.model.business.dao.WeaponDAO;
12 import com.mlw.fps.model.business.vo.Player;
13 import com.mlw.fps.model.business.vo.Weapon;
14
15 public class LookUpTag extends javax.servlet.jsp.tagext.BodyTagSupport
16 {
17 private String name;
18 private String property;
19 private String scope;
20 private String type;
21
22 public LookUpTag()
23 {
24 super();
25 }
26
27 public void release()
28 {
29 type = null;
30 name = null;
31 scope = null;
32 property = null;
33 }
34
35 public int doStartTag() throws JspException
36 {
37 String pk = (String)RequestUtils.lookup(pageContext, name, property, scope);
38 if( "player".equals(type) )
39 {
40 Player player = ((PlayerDAO)DAOFactory.getDAO(PlayerDAO.class.getName())).getPlayerByPk(pk);
41 ResponseUtils.write(pageContext, player.getName());
42 }
43 else if( "weapon".equals(type) )
44 {
45 Weapon weapon = ((WeaponDAO)DAOFactory.getDAO(WeaponDAO.class.getName())).getWeaponByPk(pk);
46 StringBuffer sb = new StringBuffer();
47
48 sb.append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
49 sb.append(" <tr><td class=\"weapon\" width=\"50%\" align=\"right\" >");
50 sb.append(weapon.getName());
51 sb.append("</td><td class=\"weapon\" width=\"50%\" align=\"left\" >");
52 sb.append(" <img border=\"0\" src=\"/fps/images/weapons/2.0/").append(SystemProperties.getProperty("game")).append("_").append(weapon.getName()).append(".gif\" />" );
53 sb.append("</td></tr>");
54 sb.append("</table>");
55
56 ResponseUtils.write(pageContext, sb.toString() );
57 }
58
59
60 return SKIP_BODY;
61 }
62
63
64 /*** Setter for property name.
65 * @param name New value of property name.
66 */
67 public void setName(String name)
68 {
69 this.name = name;
70 }
71
72 /*** Setter for property property.
73 * @param property New value of property property.
74 */
75 public void setProperty(String property)
76 {
77 this.property = property;
78 }
79
80 /*** Setter for property scope.
81 * @param scope New value of property scope.
82 */
83 public void setScope(String scope)
84 {
85 this.scope = scope;
86 }
87
88 /*** Setter for property type.
89 * @param type New value of property type.
90 */
91 public void setType(String type)
92 {
93 this.type = type;
94 }
95
96 }
This page was automatically generated by Maven