On Mon, 15 Mar 2004 ddd ddd wrote : > > >Hi All > > I am new bie and learning to populate the drop box by all different ways . > >1. By Collections of strings >2. By collections beans >3. Hard coding >I am unable to achieve even first way tried a lot but failed can any body suggest me >where I am wrong. Also pl. suggest me how the “collection of beans” will be coded . >any body has simple java nd jsp code please Post me > > >Manay many thanks > > >Regrds >StrutsGuy >[EMAIL PROTECTED] > > > Below is Jps ,stutsconfig and java files and errors of browser . > ><%@ page language="java" import="StudentForm" %> ><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> ><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> ><jsp:useBean id="sf" class="StudentForm" scope="session" > ></jsp:useBean> ><html:html> ><head> ><title><bean:message key="hello"/> </title> ></head> ><body> ><B>LOGIN PAGE <B> ><html:errors /> ><html:form action="/LoginForm" focus="studentid" onsubmit="return >validateStudentForm(this);"> ><table> ><html:select property="passwd" > ><html:options name="sf" labelName="sf" /> ></html:select> ><td>LOGIN ID</td> ><td><html:text property="student"/></td> ><td>PASSWORD</td> ><td><html:text property="passwd"/> </td> ></table> ><html:submit><bean:message key="button"/></html:submit> ><html:reset><bean:message key="reset"/></html:reset> ><html:cancel><bean:message key="cancel" /></html:cancel> ></html:form> ><html:javascript formName="studentForm" dynamicJavascript="true" >staticJavascript="true"/> ><script language="Javascript1.1" src="staticJavascript.jsp"></script> ></body> ></html:html> > > >import org.apache.struts.action.ActionError; >import org.apache.struts.action.ActionErrors; >import org.apache.struts.action.Action; >import org.apache.struts.action.ActionForward; >import org.apache.struts.action.ActionMapping; >import org.apache.struts.action.ActionForm; >import org.apache.commons.beanutils.BeanUtils; >import javax.servlet.http.HttpServletRequest; >import javax.servlet.http.HttpServletResponse; >import java.util.*; >import javax.servlet.jsp.PageContext; > >// use The seSSion stuf >public class StudentAction extends Action >{ > public ActionForward execute( ActionMapping map,ActionForm form, HttpServletRequest > req , HttpServletResponse res) throws Exception > { > String action = req.getParameter("action"); > if (action == null) > { > StudentDatabase stBase = new StudentDatabase (); > StudentForm sf= new StudentForm(); > String[] str = stBase.getAllNames(); > String strng ="blah" ; > sf.setPasswd(strng); > req.setAttribute("sf", sf); > ActionErrors er= new ActionErrors(); > er.add(ActionErrors.GLOBAL_ERROR , new ActionError("errorRakesh")); > if(!er.empty()) > { > saveErrors(req,er); > return(map.findForward("RakyError")); > } > else > return(map.findForward("RakyCancel")); > } > else > { > return(map.findForward("RakyCancel")); > } > >}// end of class >} > >import org.apache.struts.action.ActionForm; >import org.apache.struts.action.ActionMapping; >import javax.servlet.http.HttpServletRequest; >import org.apache.struts.action.ActionErrors; >import org.apache.struts.action.*; > import org.apache.struts.validator.ValidatorForm; > >public class StudentForm extends ValidatorForm >{ > private int student =0; > private String passwd = null; >public StudentForm() >{ > student=0; >passwd = new String(); >} > public StudentForm( int student ,String passwd) > { > student=student; > passwd= passwd; > } >public int getStudent() >{ >return this.student; >} >public void setStudent(int student) >{ >this.student=student; >} > >public String getPasswd( ) >{ >return this.passwd; >} >public void setPasswd(String passwd) >{ >this.passwd=passwd; >} >public void reset(ActionMapping mapping ,HttpServletRequest request) >{ >this.student=0; >this.passwd=null; >} >public ActionErrors validate( ActionMapping map,HttpServletRequest req) >{ > ActionErrors errors=super.validate(map,req); > if(student == 0) > { > System.out.println("HELLO blah "+student); > errors.add("student", new ActionError("IDProblem")); > } >return errors; >} // end of action errors >}// end of Student from class > > ><?xml version="1.0" encoding="ISO-8859-1" ?> ><!DOCTYPE struts-config PUBLIC > "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" > "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd"> ><!-- This is the Struts configuration file for the rakesh application --> ><struts-config> > <!-- Form bean smust be maped here first --> ><form-beans> ><form-bean name="StudentForm" type="StudentForm"/> ></form-beans> ><!-- All Action msut be mapped here --> ><action-mappings> ><!-- Calling a jsp page through link --> ><action path="/LoginJsp" forward="/Login.jsp"/> ><action path="/LoginForm" type="StudentAction" name="StudentForm" scope="request" >validate="true"> ><forward name="RakySuccess" path="/Start.jsp"/> ><forward name="RakyCancel" path="/Start.jsp"/> ><forward name="RakyError" path="/Start.jsp"/> ></action> ></action-mappings> ><message-resources parameter="propertyInfo" /> > <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> > <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, > /WEB-INF/validation.xml"/> > </plug-in> ></struts-config> > >propertyInfo.properties >hello=This is test page >start=This is first page of the application >info=This page stores contains text files and drop downs >error=There is problem please have a look >submit=ADD TO DATABASE >clear=Clear the Data >cancel=Cancel Button >click=Please Click to start the application >button=Login >cancel=CancelButton >reset=ResetButton >IDProblem=There is problem in id has greater value than 4 pl. recheck it >prompt.username= Please Enter the User Name by blah >prompt.password=Please enter the password by bla >errors.required={0} is required. >errors.minlength={0} cannot be less than {1} characters. >errors.maxlength={0} cannot be greater than {2} characters. >errors.invalid={0} is invalid. >errors.byte={0} must be an byte. >errors.short={0} must be an short. >errors.integer={0} must be an integer. >errors.long={0} must be an long. >errors.float={0} must be an float. >errors.double={0} must be an double. >errors.date={0} is not a date. >errors.range={0} is not in the range {1} through {2}. >errors.creditcard={0} is not a valid credit card number. >errors.email={0} is an invalid e-mail address. >rakeshErROR=This is first ssuccessfyl errro by blah >errorRakesh=This is type of error in jsp page > > >eError is > >HTTP Status 500 - >________________________________________ >type Exception report >message >description The server encountered an internal error () that prevented it from >fulfilling this request. >exception >org.apache.jasper.JasperException: Cannot create iterator for [EMAIL PROTECTED] > at > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254) > at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at > org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) > at > org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432) > at > org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356) > at > org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1014) > at > org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:961) > at > org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:544) > at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:252) > at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292) > at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) > at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) > at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline > > >On Sun, 14 Mar 2004 Timo Tjäder wrote : > >Hi, > > > >I have problems with optionsCollection, when used with <html:select> > >custom tag. > > > >1. I set up in a bean LabelValueBean object in a Vector > >2. pass it back to form and try to create a <html:selec> > > > >This part should display a combo box with options, but > >it just does not work. It does not display anything. > > > >Html code is as follows: > > > ><html:select style="font-size: 10px;" property="goTo" size="1"> > ><html:optionsCollection name="PageDetailView" > >property="totalNumOfPagesCollection"/> > ></html:select> > > > >I have checked using struts "bean:write" the contents of > >the object. Bean write claims that totalNumOfPages really > >contains LabelValueBean-objects (14 peaces). > >LabelValueBean[1, 1], LabelValueBean[2, 2], LabelValueBean[3, 3], > >... > > > >So, does anyone know how to reference to this object correctly. > >Current solution does not diaplay anything to the screen. > > > >Thanks, > > > >Timo > > > >So what I'd like to do is display a selection list of > >all availabele pages from which user choose one and press > >a goTo page button. This is quite common web control in > >any web pages. > > > > > >.... > ><logic:equal name="PageDetailView" property="linkType" > >value="add-total-num-of-pages-collection"> > ><bean:write name="PageDetailView.totalNumOfPagesCollection" > >property="LabelValueBean"/> > > > ><html:select style="font-size: 10px;" property="goTo" size="1"> > ><html:optionsCollection name="PageDetailView" > >property="totalNumOfPagesCollection"/> > ></html:select> > ></logic:equal> > > > > > > > >[1] 2 3 4 5 next » Result 14 pages. > >.... > >ÄLabelValueBeanÄ1, 1Å, LabelValueBeanÄ2, 2Å, LabelValueBeanÄ3, 3Å, > >LabelValueBeanÄ4, 4Å, LabelValueBeanÄ5, 5Å, LabelValueBeanÄ6, 6Å, > >LabelValueBeanÄ7, 7Å, LabelValueBeanÄ8, 8Å, LabelValueBeanÄ9, 9Å, > >LabelValueBeanÄ10, 10Å, LabelValueBeanÄ11, 11Å, LabelValueBeanÄ12, > >12Å, LabelValueBeanÄ13, 13Å, LabelValueBeanÄ14, 14ÅÅ > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >