Hi Trevis, thanks for reply. I need help urgently.

On Jul 30, 1:05 am, Trevis <[email protected]> wrote:
> Shot in the dark here but the first thing i would check is are you
> setting the method type on your form panel? Sounds like you need to
> set it to "POST".  (FromPanel.METHOD_POST constant is defined for
> doing this)

The following is the portion of my code, please check it out any
problem on it.

Eclipse 3.4 + GWT 1.7.+ Chrome (default browser)
=========================================================
CwTextArea.java
=========================================================

private FormPanel homeForm = new FormPanel();
private HorizontalPanel identifyPanel = new HorizontalPanel();
private TextArea identifyTextArea = new TextArea();
private VerticalPanel leftHomePanel = new VerticalPanel();
private VerticalPanel rightHomePanel = new VerticalPanel();
private Label titleInlineLabel = new Label("Enter text or a webpage
URL");
private Button identifyButton = new Button("Identify Language");
private Label identifyResultLabel = new Label("(result displayed
here!)");
private HTML h = new HTML();

/**
 * Initialize this example.
 */
@ShowcaseSource
@Override
public Widget onInitialize() {
        
////////////////////////////////////////////////////////////////////////////////
        // Text and Web tab
        
////////////////////////////////////////////////////////////////////////////////
        // Create a web page form
        homeForm.setAction(GWT.getModuleBaseURL()+"textarea");
        homeForm.setMethod(FormPanel.METHOD_POST);

        // Create a panel to hold all of the form widgets.
        homeForm.setWidget(identifyPanel);

        // set the text area size.
        identifyTextArea.setCharacterWidth(40);
        identifyTextArea.setVisibleLines(10);
        identifyTextArea.setName("homeTextArea");

        // Assemble Home tab vertical panel of text area.
        leftHomePanel.setWidth("400px");
        leftHomePanel.add(titleInlineLabel);
        leftHomePanel.add(identifyTextArea);
        leftHomePanel.add(identifyButton);

        // Assemble identify result label into vertical result panel
        rightHomePanel.add(identifyResultLabel);

        // Assemble Home tab vertical panel.
        identifyPanel.setHeight("400px");
        identifyPanel.add(leftHomePanel);
        identifyPanel.add(rightHomePanel);

        /*
         * Listen for mouse events on the Add button of the text area.
         */
        identifyButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                        if (identifyTextArea.getText().length() == 0) {
                                Window.alert("The text area must not be empty");
                                identifyTextArea.selectAll();
                                return;
                        }
                        else
                                homeForm.submit();
                }
        });

        homeForm.addFormHandler(new FormHandler() {
                public void onSubmit(FormSubmitEvent event) {
                        System.out.println(event);
                        identifyTextArea.setFocus(true);
                        identifyResultLabel.setText(identifyTextArea.getText());
                }

                public void onSubmitComplete(FormSubmitCompleteEvent event) {
                        System.out.println(event);
                }

        });

        return identifyPanel;
}


=========================================================
TextAreaServlet.java
=========================================================
@SuppressWarnings("serial")
public class TextAreaServlet extends HttpServlet {

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse
resp)
        throws ServletException, IOException {
                resp.setContentType("text/html");
                System.out.println("servlet respond!");
                String oriSource = req.getParameter("homeTextArea"); //read 
from the
form of text area
                System.out.println(oriSource);
        }

        // to override the doPost()
        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse
resp)
        throws ServletException, IOException {
                super.doGet(req, resp);
        }
}


=========================================================
web.xml
=========================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>
  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>ReadMeSystem.html</welcome-file>
  </welcome-file-list>

<servlet>
        <servlet-name>textareaServlet</servlet-name>
        <servlet-class>com.google.gwt.sample.showcase.server.TextAreaServlet</
servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>textareaServlet</servlet-name>
        <url-pattern>/readmesystem/textarea</url-pattern>
</servlet-mapping>
</web-app>


=========================================================
output in Eclipse console
=========================================================
first event: com.google.gwt.user.client.ui.FormSubmitEvent[source=
<FORM method=post action=http://localhost:8080/readmesystem/textarea
target=FormPanel_1></FORM>]


=========================================================
where hosted mode console no respond at all. Then, if i try add
servlet in my ReadMeSystem.gwt.xml,
<servlet path="/textarea"
class="com.google.gwt.sample.showcase.server.TextAreaServlet"/>,
same issue happened. Note that, i have try this in a default new web
application project using GWT,
everything work smoothly, servlet got reply, onSubmitComplete is
fired. But when i switched to GWT showcase
as stated in first post, the problem occurred. I am not sure whether
GWT showcase disable any communication with
servlet or server, which may be a cause on it.

In addition, i try compile and browse in the IE and Chrome. IE respond
as the hosted mode browser, and Chrome
is a little bit strange, pop up a new page, with correct servlet url,
and the error listed in the first post. Then, if i try
add a parameter in url like this,
http://localhost:8080/readmesystem/textarea?homeTextArea=Hello,

Eclipse console replied as following,
servlet respond!
Hello

Hosted Mode console shown this,
[INFO] 200 - GET /readmesystem/textarea?homeTextArea=Hello (127.0.0.1)

So, once again, i hope you all can help me track the problem, thanks
in advance.

regards,
Simon



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to