C
cactie
Gast
Hallo zusammen, ich benutze html
ptionsCollection, um einen Combobox zu generieren. Das Problem ist, dass der Wert nicht im Combobox angezeigt werden kann.
Hier ist mein Code
index.jsp
<%@ page language="java"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>CSV Export</title>
</head>
<body>
<html:form action="/ChooseHeader">
<table width="80%" align="center">
<tr>
<td>Destination</td>
</tr>
<tr>
<td><html:select property="destination" name="ChooseHeaderFormBean">
<html
ptionsCollection name="ChooseHeaderFormBean" property="destination"/>
</html:select></td>
</tr>
<tr>
<td colspan="1"><html:submit /></td>
</tr>
</table>
</html:form>
</body>
</html>
struts-config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<data-sources>
</data-sources>
<form-beans>
<form-bean type="test.forms.ChooseHeaderFormBean" name="ChooseHeaderFormBean">
</form-bean>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
</global-forwards>
<action-mappings>
<action path="/ChooseHeader" type="test.action.HeaderAction" name="ChooseHeaderFormBean" scope="session" input="/index.jsp">
<forward path="/WEB-INF/pms_query.jsp" name="pms_success">
</forward>
</action>
</action-mappings>
<message-resources parameter="test.resources.ApplicationResources"/>
</struts-config>
HeaderAction
FormBean
Kann jemand mir sagen, was ich hier falsch gemacht habe?
Hier ist mein Code
index.jsp
<%@ page language="java"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>CSV Export</title>
</head>
<body>
<html:form action="/ChooseHeader">
<table width="80%" align="center">
<tr>
<td>Destination</td>
</tr>
<tr>
<td><html:select property="destination" name="ChooseHeaderFormBean">
<html
</html:select></td>
</tr>
<tr>
<td colspan="1"><html:submit /></td>
</tr>
</table>
</html:form>
</body>
</html>
struts-config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<data-sources>
</data-sources>
<form-beans>
<form-bean type="test.forms.ChooseHeaderFormBean" name="ChooseHeaderFormBean">
</form-bean>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
</global-forwards>
<action-mappings>
<action path="/ChooseHeader" type="test.action.HeaderAction" name="ChooseHeaderFormBean" scope="session" input="/index.jsp">
<forward path="/WEB-INF/pms_query.jsp" name="pms_success">
</forward>
</action>
</action-mappings>
<message-resources parameter="test.resources.ApplicationResources"/>
</struts-config>
HeaderAction
Code:
package test.action;
import java.util.ArrayList;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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.util.LabelValueBean;
import test.forms.ChooseHeaderFormBean;
public final class HeaderAction extends Action {
public HeaderAction() {
}
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse respons) throws Exception {
ChooseHeaderFormBean chooseHeaderFormBean = (ChooseHeaderFormBean) form;
Vector entries = new Vector(10);
entries.add(new LabelValueBean("PMS","0"));
entries.add(new LabelValueBean("SDK","1"));
chooseHeaderFormBean.setDestination(entries);
return (mapping.findForward("pms_success"));
}
}
FormBean
Code:
package test.forms;
import java.util.Collection;
import java.util.Vector;
import org.apache.struts.action.ActionForm;
import org.apache.struts.util.LabelValueBean;
public class ChooseHeaderFormBean extends ActionForm{
/**
*
*/
private static final long serialVersionUID = 1L;
int destinationID;
String destinationName;
String selectedHeader = "";
Collection destination;
public ChooseHeaderFormBean(){
}
public String getSelectedHeader() {
return selectedHeader;
}
public void setSelectedHeader(String selectedHeader) {
this.selectedHeader = selectedHeader;
}
public int getDestinationID() {
return destinationID;
}
public void setDestinationID(int destinationID) {
this.destinationID = destinationID;
}
public String getDestinationName() {
return destinationName;
}
public void setDestinationName(String destinationName) {
this.destinationName = destinationName;
}
public Collection getDestination() {
return destination;
}
public void setDestination(Collection destination) {
this.destination = destination;
}
}
Kann jemand mir sagen, was ich hier falsch gemacht habe?