• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting selected values from Struts combo box

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody.

I have a JSP to get 2 input data, one field is a combo and other is a text.

I fill the combo through a javabean:

<jsp:useBean id="fillCombo" scope="session"
class="com.anmex.javabeans.LlenaComboExamenes"
type="com.anmex.javabeans.LlenaComboExamenes" />

<html:form action="/SearchEvaluation">

<%/* Manda ejecutarse el bean que trae los cursos */%>
<%llenaComboExamenesBean.execute("", "");%>

<html:select property="examen">
<html ption value="">SELECCIONE UN CURSO DE LA LISTA</html ption>
<%if (fillCombo.getRows()!= null) {
for (int i0=0; i0<fillCombo.getRows().length; i0++) {
if(fillCombo.getRows()[i0].getEXAM_EXAID().toString().equals(retexamen)){
%>
<html ption value="<%=fillCombo.getRows()[i0].getEXAID().toString()%>">
<%=fillCombo.getRows()[i0].getEXADSC().toString()%>
</html ption>
<%}
else{%>
<html ption value="<%=fillCombo.getRows()[i0].getEXAID().toString()%>">
<%=fillCombo.getRows()[i0].getEXADSC().toString()%>
</html ption>
<%}
}
}%>
</html:select></TD>

After submit the form to validate data, i return back to the same page for show the errors founded into FormBean or ActionForm...

Also, i return back the values to the JSP from ActionForm with the initial values, all it's rigth, but as you can see, into the JSP i separated the options SELECTED and all others, to be able to show the selected values when the JSP is showed again.

How can i tell to Struts tags, wich one option was selected since the first send.

I mean, do exist some attribute for Struts tag <html ption> like selected for <OPTION> HTML tag???

Thanks a lot.
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Josue,
Welcome to JavaRanch!

The options exist for Struts equivalent to those in HTML. You can see them documented in the Struts reference.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checking the "Disable smilies in this post" checkbox and surrounding your code with a code block will make it much easier to read.

I cannot quite tell exactly what you are doing with all the Javascript code, but I think it is not needed. If examen is a property on your form, then whatever option value with the matching id will be selected for you. This is all handled by the html tags. Check out the html: optionsCollection tag. Your code might just need to look like this:


- Brent
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic