Hello, im facing a problem on String and String[]. I pass a value from another jsp , and i get the value at backend. Then i need to set this value into String[] which index 11 and pass back to jsp and show it . Anyone can give me hints or solution on that?Thanks in advanced, and hope to get your replies soon....:)
Problem with String and String []
Collapse
X
-
Which part do you need help with specifically?Originally posted by KusoYumiHello, im facing a problem on String and String[]. I pass a value from another jsp , and i get the value at backend. Then i need to set this value into String[] which index 11 and pass back to jsp and show it . Anyone can give me hints or solution on that?Thanks in advanced, and hope to get your replies soon....:)
You did say you can pass parameters between JSPs. -
Ya, i can get the value(i called it stall's id) from page A to page B. Then i need to place stallId in text box which in display table.Originally posted by r035198xWhich part do you need help with specifically?
You did say you can pass parameters between JSPs.
at jsp:
[CODE=html] <display:tabl e name="paramsArr " cellspacing="0" cellpadding="0" requestURI="" id="paramsArr" pagesize="40" class="table">
<display:colu mn property="name" escapeXml="true " sortable="true" titleKey="downl oadParameterFor m.name" style="width: 25%"/>
<display:colu mn titleKey="downl oadParameterFor m.value" style="width: 30%">
<html:text property="value Arr" size="29" maxlength="30"/>
</display:column>
<display:colu mn titleKey="downl oadParameterFor m.insert" style="width: 15%; padding-left: 15px" media="html">
<html:multibo x property="inser t" >
<c:set var="index" value="${index+ 1}"/>
</display:column>
</display:table>[/CODE]
Backend :
[CODE=java] String[] paramCons = Constants.PARAM _NAMES;
List paramsArr = new ArrayList();
String[] result = new String[paramCons.lengt h];
String[] noValue = new String[paramCons.lengt h];
for(int i=0; i<paramCons.len gth; i++){
ParameterDto paramDto = new ParameterDto();
paramDto.setNam e(paramCons[i]);
paramDto.setVal ueArr(noValue);
if(paramCons[i].equals("MERCHA NT") && (parameterForm. getStallId()!=n ull && !parameterForm. getStallId().eq uals(""))){
Stall stall = stallMgr.getSta ll(new Long(parameterF orm.getStallId( )));
paramDto.setNam e("MERCHANT") ;
result[i] = stall.getStallI d(); // this is stallId, eg: 1234778
paramDto.setVal ueArr(result);
}
paramsArr.add(p aramDto);
}
[/CODE]
** paramDto is a bean
I hope those codes will provide more explanation/understand to you....What i need to solve is display the stallId in the correct text box in display tag. Thank for reply.Comment
-
I have make it already, anyway, thank you very much on reply!
Below is the solution, if anybody has same problem with me, can have look! :)
Backend code still remain, but change setValueArr( ) to setValue( ), which is set value as string, not string[] anymore.
But there is changes at jsp:
<c:set var="index" value ="0"/>
<c:set var="valueIndex " value="0"/>
<display:tabl e name="paramsArr " cellspacing="0" cellpadding="0" requestURI="" id="paramsArr" pagesize="40" class="table">
<display:colu mn property="name" escapeXml="true " sortable="true" titleKey="downl oadParameterFor m.name" style="width: 25%"/>
<display:colu mn titleKey="downl oadParameterFor m.value" style="width: 30%" >
<html:text property="value Arr" size="29" maxlength="30" value="${params Arr.value}" />
<c:set var="valueIndex " value="${valueI ndex+1}"/>
</display:column>
<display:colu mn titleKey="downl oadParameterFor m.insert" style="width: 15%; padding-left: 15px" media="html">
<html:multibo x property="inser t"><c:out value="${index} "/></html:multibox>
<c:set var="index" value="${index+ 1}"/>
</display:column>
</display:table>Comment
Comment