• 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

Variable for a form value?

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy all.

On my jsp page, I'm displaying a list of options from a database:

display.jsp


However, the value assigned to each radio button is literally the String "<% custOrderBean.getDate().get(i);%>".

Is there anyway for me to assign the String value of custOrderBean.getDate().get(i) into the radio buttons value?
 
Karl Beowulph
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, I think I've solved it by using the following:



It's not quite what I wanted, but it should suffice.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
KB,
You had another question which mysteriously disappeared as I replied to it.

It had to do with phone entries and I assume you're using Struts.

My reply:
It is very possible. It'll be kind of tricky and you'll probably need to use a "map-backed" form. I put map-backed in quotes because I think you're better off using an ArrayList.

Here is an example:

<% int count = 0; %>
<logic:iterate id="idNotUsed" collection='<%= getMyListSomehow() %>'>
<html:text property='<%= "value(name" + count++ + ")" %>' />
<html:text property='<%= "value(addr" + count++ + ")" %>' />
<html:text property='<%= "value(phon" + count++ + ")" %>' />
</logic:iterate>

public void setValue(String key, Object value){
int count = Integer.parseInt(key.substring(4, key.length()-1));
String key = key.substring(0,4);
...
}
public Object getValue(String key){
int count = Integer.parseInt(key.substring(4, key.length()-1));
String key = key.substring(0,4);
...
return myList.getIndex(
}
 
Karl Beowulph
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I deleted the question because I had read elsewhere that Struts wasn't designed to handle what I was asking for (a JSP script with the ability to create Forms) as all Forms are created when then JSP first loads.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

I read the post by you regarding map backed forms. I am using map backed forms to generate a search criteria page dynamically. I could have <html:radio .. > as one of the elements on the JSP.

My problem is regarding prepopulation of the JSP page fields which uses map backed form. Is it possible to prepopulate th JSP when that JSP is genetated using map-backed forms?

Here is the code snippet I am using..

<c:when test="${queryForms.displayType == 'RadioButton'}">
<c:set var="displayTypeName" value="${queryForms.displayTypeName}"/>
<c:set var="displayValue" value="${queryForms.displayValue}"/>
<c:set var="delim" value=";"/>
<c:set var="buttonNameArray" value="${fn:split(displayTypeName, delim)}"/>
<c:set var="buttonValueArray" value="${fn:split(displayValue, delim)}"/>
<c:forEach begin="0" end="${fn:length(buttonNameArray) - 1}" var="token">
<html:radio property="param(${queryForms.paramName})" value="${buttonValueArray[token]}"/>${buttonNameArray[token]}   
</c:forEach>
</c:when>

Please let me know if anybody has idea about this.

Thanks,
Archana.
 
reply
    Bookmark Topic Watch Topic
  • New Topic