uma combobox é usada pra escolher um item entre uma lista de vários. Digamos q no seu actionform vc tenha uma propriedade chamada Estado, e vc quer que o usuário escolha qual estado ele quer dentre a lista de estados… A combobox vai retornar um só valor pra propriedade que você escolher! Lá no struts-examples.war (que vem com o struts) tem vários exemplos disso, dê uma olhada lá
Dae galera valeu mesmo pela força…
ta rodando sussi agora aqui =)
moçada como funciona esse lance de avaliação…o 5 é a nota mais alta?
ontem avaliei…mas hoje quero avaliar com certeza…
abração
e vai mais um probleminha básico agora de java:
public static Vector getEstados() throws SQLException
{
Connection conn = ConexaoDB.getConnection();
Statement stm = conn.createStatement();
ResultSet rs;
Vector vEstados = new Vector();
Estado estados = new Estado();
try
{
rs = stm.executeQuery("select * from Estado");
int colCount = rs.getMetaData().getColumnCount();
while (rs.next())
{
System.out.println("codigo do estado");
System.out.println(rs.getString(1));
estados.setIdEstado(rs.getString(1));
System.out.println("nome do estado");
System.out.println(rs.getString(2));
estados.setNomeEstado(rs.getString(2));
vEstados.addElement(estados);
}
rs.close();
stm.close();
}
catch (Exception e)
{
e.printStackTrace();
}
for(int i = 0; i<vEstados.size(); i++)
{
estados = (Estado) vEstados.elementAt(i);
System.out.println("Esse estado : " + i + " eh o : " + estados.getNomeEstado());
}
return vEstados;
}
esse é um método que iria carregar o vetor com os estados…
mas não sei pq ele tá carregando o vetor com o ultimo estado…
entao vem todos os registros no vetor com um unico valor
alguém sabe pq?
Sou novo aqui, mas parace que sim, 5 estrelinhas eh o mais alto…
quanto ao erro, melhor postar em outro lugar, pra que mais gente possa ver e talz! to meio sem tempo agora! (to indo pra casa)! fuiz
Galera ta sussi deu tudo certo … valeu
Estou com um problema parecido. Ele dá o seguinte erro:
Isso é o que está no meu JSP:
<%-- ***************************************************************** --%>
<%-- NEW BRAND ARCHITECTURE --%>
<%-- ***************************************************************** --%>
<tr><td class="formrows"><bean:message key="buyers.guide.fiber.newbrand"/></td><td class="formrows">
<logic:equal name="isVanguard" value="true">
<html:select property="newbrandProperty" styleClass="formelements">
<html:option value="ANY"><bean:message key="buyers.guide.any"/></html:option>
<html:options collection="scoreGenericNewBrands" property="newbrand" labelProperty="newbrand" />
</html:select>
</logic:equal>
<logic:equal name="isMS" value="true">
<html:select property="newbrandProperty" styleClass="formelements">
<html:option value="ANY"><bean:message key="buyers.guide.any"/></html:option>
<html:options collection="scoreMasterstoreNewBrands" property="newbrand" labelProperty="newbrand" />
</html:select>
</logic:equal>
<logic:equal name="isSFC" value="true">
<html:select property="newbrandProperty" styleClass="formelements">
<html:option value="ANY"><bean:message key="buyers.guide.any"/></html:option>
<html:options collection="scoreDFCNewBrands" property="newbrand" labelProperty="newbrand" />
</html:select>
</logic:equal>
</td></tr>
<%-- ***************************************************************** --%>
Esse é meu form:
package com.smlink.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import java.util.*;
import com.smlink.busobj.*;
/** Form that supports {@link BuyersGuideAction}
* @author Matheus Goncalves
*/
public class BuyersGuideForm extends ActionForm {
private String millFamily = null;
private String mill = null;
private String construction = null;
private String fiberProgram = null;
private String brand = null;
private String newbrandProperty = null;
private String dealertype = null;
private String weightrange = null;
private String proceed = null;
private String refresh = null;
public String getMillFamily() {return (millFamily);}
public String getMill() {return (mill);}
public String getConstruction() {return (construction);}
public String getFiberProgram() {return (fiberProgram);}
public String getBrand() {return (brand);}
public String getnewbrandProperty() {return (newbrandProperty);}
public String getDealertype() {return (dealertype);}
public String getWeightrange() {return (weightrange);}
public String getProceed() {return (proceed);}
public String getRefresh() {return (refresh);}
public void setMillFamily (String millFamily) {this.millFamily = millFamily;}
public void setMill (String mill) {this.mill = mill;}
public void setConstruction (String construction) {this.construction = construction;}
public void setFiberProgram (String fiberProgram) {this.fiberProgram = fiberProgram;}
public void setBrand (String brand) {this.brand = brand;}
public void setNewBrand (String NewBrand) {this.newbrandProperty = NewBrand;}
public void setDealertype (String dealertype) {this.dealertype = dealertype;}
public void setWeightrange (String weightrange) {this.weightrange = weightrange;}
public void setProceed (String proceed) {this.proceed = proceed;}
public void setRefresh (String refresh) {this.refresh = refresh;}
public void clear() {
this.millFamily = null;
this.mill = null;
this.construction = null;
this.fiberProgram = null;
this.brand = null;
this.newbrandProperty = null;
this.dealertype = null;
this.weightrange = null;
this.proceed = null;
this.refresh = null;
}
public void reset(ActionMapping mapping,
HttpServletRequest request) {
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
// if ( (businessType == null) || (businessType.length() == 0) ) {
// errors.add("BusinessType", new ActionError("errors.businesstype.required"));
// }
// clear all the buttons if there is an error
if (!errors.isEmpty()) {
}
return errors;
}
}
E o Action:
package com.smlink.struts;
import java.util.*;
import java.lang.Math;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.util.MessageResources;
import com.smlink.busobj.*;
import com.smlink.util.*;
/** Get input from the {@link BuyersGuideForm} and list carpet products.
* @author David D. Christian
*/
public class BuyersGuideAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String millFamily = null;
String mill = null;
String construction = null;
String fiberProgram = null;
String brand = null;
String newbrandProperty = null;
String dealertype = null;
String weightrange = null;
String proceed = null;
String refresh = null;
String pagingHTML = ""; // these are the variables used for paging
int startRec = 1;
int endRec = 50;
String bulkPage = (String)request.getParameter("bulkpage");
String partialAnchor = "<a right' >Result Page: \n";
if ( selectedPage > 1 ) {
pagingHTML += partialAnchor + strPrevPage + "'>Previous</a> \n";
}
for ( int i=1; i<=pageCnt; i++ ) {
if ( i==selectedPage ) {
pagingHTML += bulkPage + " ";
} else {
String strCurPage = new Integer(i).toString();
pagingHTML += partialAnchor + strCurPage + "'>" + strCurPage + "</a> \n";
}
}
if ( selectedPage < pageCnt ) {
pagingHTML += partialAnchor + strNextPage + "'>Next</a> \n";
}
pagingHTML += "</div>\n";
}
int forLoopCnt = 0;
ArrayList pagedResults = new ArrayList();
for(Iterator it = results.iterator(); it.hasNext(); ){
ScoreStyle scoreStyle = (ScoreStyle) it.next();
forLoopCnt += 1;
if ( forLoopCnt > endRec ) break;
if ( forLoopCnt >= startRec ) {
pagedResults.add(scoreStyle);
}
}
request.setAttribute("BulkPageHTML", pagingHTML);
request.setAttribute("scoreStyles", pagedResults);
}
}
}
// Report any errors we have discovered
if (!errors.isEmpty()) {
//Logger.sysOut("-->BuyersGuideAction: Had Errors");
saveErrors(request, errors);
}
// Forward to the appropriate View
//Logger.sysOut("-->BuyersGuideAction: Leaving with target="+target);
//Logger.sysOut("-->BuyersGuideAction: mapping.findForward(target)="+mapping.findForward(target));
return (mapping.findForward(target));
}
}
Alguém tem alguma idéia do que é que eu estou esquecendo? Tô batendo cabeça aqui.
O nome da propriedade está assim justamente pra dar um destaque pra ela, pra eu tentar enxergar.
Obrigado desde já pela ajuda.