Problem with String and String []

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KusoYumi
    New Member
    • Mar 2008
    • 11

    Problem with String and String []

    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....:)
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by KusoYumi
    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....:)
    Which part do you need help with specifically?
    You did say you can pass parameters between JSPs.

    Comment

    • KusoYumi
      New Member
      • Mar 2008
      • 11

      #3
      Originally posted by r035198x
      Which part do you need help with specifically?
      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.

      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

      • KusoYumi
        New Member
        • Mar 2008
        • 11

        #4
        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

        Working...