javascriptsplitspringsource

how to Split the String values returned from the method


Below is the method that returns the Set of String as follows sang1,sang2,sang3,sang4,

@SuppressWarnings("unchecked")
public String getMissedAndDelayReasonList(String missedReasonValue)
{
    if(missedReasonValue == null) return null;
    List<RCADrpDwn> drpValues = adminDAO.getDropDownValues();
    if(drpDwn.getReasonValue()!=null && missedReasonValue.equalsIgnoreCase(drpDwn.getReasonValue()) &&                         drpDwn.getDelayCategory()!=null)
    {
        uniqueMVs.add(drpDwn.getDelayCategory());
    }
}

for(String dcVal:uniqueMVs){  
    delayValue.append(dcVal).append(","); 
    return delayValue.toString();
}

and in the controller layer i am fetching the values returned from this method and adding to the object as follows

modelAndView.addObject("delayValue",  adminService.getMissedAndDelayReasonList(missedValue));

delayValue is fetched in the jsp page and displays the value in the UI Screen i am using the split function and stringutils.split() nothing is returning the appropriate value , as i need to seperate these values and make the entry in the new line as follows:

sang1
sang2
sang3
sang4

Solution

  • You can try this:

     var newString = "sang1,sang2,sang3,sang4,".replace(",","<br/>");