Jess
Jess

Reputation: 425

getting value form textbox in htmlflow of smartgwt

I added a dynamic text box to my code using htmlflow of GWT. Now I wanted the retrieve the value from the text box. Below is the code any help will be appreciable. By using the Rootpanel.get(elementID). Am able to get the element value as

O/p :

<input id="value1" 80px;="" border:="" 0px;="" border-bottom:="" 4px="" solid="" #3366ff;'="" type="textstyle='width:">

From this how do i get hold of the value that i entered in the textbox ?

    String alertText = "If pressure > ? and glucoselevel > ? ";
     String newAlertText = alertText.replace("?", "");

    numberOfPlaceHolder = alertText.length() - newAlertText.length();
    System.out.println("Num of Place holder :"+numberOfPlaceHolder);

    String[] alertblock = alertText.split("\\?");           



    StringBuffer alertHtml = new StringBuffer();


   for(int i=1; i<=numberOfPlaceHolder;i++){   


       String textbox = "<input id='value"+i+"' type=textstyle='width: 80px; border: 0px;  border-bottom: 4px solid #3366FF;' />";
       String textblock = alertblock[i-1];
       alertHtml.append(textblock);
       alertHtml.append(textbox);              


   }



   String alertTextHtml = "<div>"+alertHtml.toString()+"</div>"; 

   htmlFlow = new HTMLFlow(alertTextHtml);

   alertTextLay.addMember(htmlFlow);

   IButton saveAlertBtn = new IButton();
   saveAlertBtn.setTitle("Save Alert");
    saveAlertBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub
            LinkedHashMap<String, String> alertValueMap = new LinkedHashMap<String, String>();
            for(int i=1; i<=numberOfPlaceHolder;i++){   

                System.out.println(**RootPanel.get("value"+i));**
                //System.out.println(DOM.getElementById("value"+i).getInnerText().toString());

            }
        }
    });

Upvotes: 1

Views: 897

Answers (1)

Alain BUFERNE
Alain BUFERNE

Reputation: 2071

I think You have to get the element using the GWT Dom API and after getting the attribute of the element

Element yourElement = DOM.getElementById(YOUR_TEXT_INPUT_ELEMENT);

 String the TextOfTheInput = yourElement.getAttribute("value");

Upvotes: 1

Related Questions