Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to get "lines" of text from TextAreaItem

    Sorry if this is a repeat, but I could not find any thread with correct answer.

    here is my code segment.

    Code:
    		final DynamicForm form = new DynamicForm();
    		form.setNumCols(2);
    		form.setColWidths("15%", "85%"); 
    		final TextAreaItem textarea = new TextAreaItem();
    		textarea.setTitle("Enter New License");
    		textarea.setRequired(true);
    		textarea.setWrap(TextAreaWrap.HARD);
    		textarea.setWidth("*");
    		textarea.setColSpan(2);
    		textarea.setEndRow(true);
    		ButtonItem save = new ButtonItem("Save");
    		save.setColSpan(2);
    		save.setAlign(Alignment.CENTER);
    		save.addClickHandler(new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				// TODO Auto-generated method stub
    				if (form.validate()) {
    					Log.info("value="+textarea.getValue());
    					textarea.clearValue();
    				}
    			}
    		});
    		form.setFields(textarea, save);
    I need the end_of_line character (whatever) be part of return value from getValue() method.

    Thank you.

    #2
    please reply to above question.
    thank you.

    Comment


      #3
      By what means are you determining that line breaks are not included in the output? Note that SmartGWT normalizes line breaks to Unix format (single CR or "\n") since otherwise browsers differ by platform. If you're somehow viewing data on DOS (aka Windows) it may render without breaks depending on the tool you are viewing it with.

      Comment


        #4
        that answer my question, thank you.

        Comment


          #5
          Sample code

          Code:
          private void previewCSVData() {
          	String csv=(String) frmEmployees.getItem("csv").getValue();
          	String[] lines = csv.split("\n");
          	List<ListGridRecord> records=new ArrayList<ListGridRecord>();
          	for(String line:lines){
          		String[] fields = line.split(",");
          		ListGridRecord record=new ListGridRecord();
          		record.setAttribute("name", fields[0]);
          		record.setAttribute("phone", fields[1]);
          		record.setAttribute("city", fields[2]);
          		records.add(record);
          	}
          	grdEmployees.setData(records.toArray(new ListGridRecord[]{}));
          }

          Comment

          Working...
          X