?? votefunction.java
字號:
package cn.hxex.vote.taglib;
import java.util.Iterator;
import cn.hxex.vote.dao.IVoteDAO;
import cn.hxex.vote.model.Vote;
import cn.hxex.vote.model.VoteItem;
import cn.hxex.vote.util.DAOFactory;
import cn.hxex.vote.util.SelectConst;
public class VoteFunction {
/*將投票類型轉換為顯示信息*/
public static String voteType( String voteType ) {
return SelectConst.getVoteTypeTitle(voteType);
}
/*輸出投票類型的選項信息*/
public static String voteTypeOptions(String defaultValue) {
return SelectConst.getVoteTypeOptions(defaultValue);
}
/*將圖形類型轉換為顯示信息*/
public static String picType(String picType) {
return SelectConst.getPicTypeTitle(picType);
}
/*輸出圖形類型的選項信息*/
public static String picTypeOptions(String defaultValue) {
return SelectConst.getPicTypeOptions(defaultValue);
}
/*顯示投票信息到頁面*/
public static String display(String voteName) {
StringBuffer buf = new StringBuffer();
buf.append("<table>");
buf.append("<form method=\"post\" action=\"vote.jsp\">");
IVoteDAO dao = DAOFactory.getVoteDAO();
Vote vote = dao.getVoteByName(voteName);
if (vote != null) {
buf.append(line("<b>" + vote.getTitle() + "</b>"));
int i = 0;
Iterator items = vote.getVoteItems().iterator();
int j = 0;
while (items.hasNext()) {
VoteItem vi = (VoteItem)items.next();
String control = "<input type=\"" +
vote.getVoteType() +
"\" name=\"" +
vote.getId() + "\" value=\"" +
vi.getId() + "\">";
buf.append(line(++i + "." + control + vi.getTitle()));
j++;
}
System.out.println("j = " + j);
}
buf.append("<tr><td align=\"center\">");
buf.append("<input type=\"submit\" value=\"投票\">");
buf.append(" ");
buf.append("<input type=\"reset\" value=\"重置\">");
buf.append("<input type=\"hidden\" name=\"id\" value=\"" +
vote.getId() + "\">");
buf.append("</td></tr>");
buf.append("</table>");
return buf.toString();
}
protected static String line(String line) {
return "<tr><td>" + line + "</td></tr>";
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -