onSubmitComplete is not working with GWT Showcase

111 views
Skip to first unread message

Simon

unread,
Jul 28, 2009, 11:15:13 PM7/28/09
to Google Web Toolkit
Hi all,

I have a problem regarding FormPanel. Initially, i am working on
default GWT application for submit text through textarea and upload
file to server, all the events are handled by servlet, works pretty
fine. However, when i switched to using the GWT Showcase framework
(http://gwt.google.com/samples/Showcase/Showcase.html), all my
FormPanel events having problem on onSubmitComplete, it is no respond
at all. But if i try to send the request through URL, the servlet is
responded and all the parameters displayed as predicted. Second thing,
when i try compile and browse in the default IE browser (Chrome), i
click the submit button, it popup a new page and show the correct
servlet url, but the content is

HTTP ERROR: 405
HTTP method Get is not supported by this url
RequestURI=.readmesystem/textarea
Powered by Jetty://

again, i try insert some parameters after textarea?Variable=Hello,
servlet is just working fine.

I try search the forum and i found this issue (http://code.google.com/
p/google-web-toolkit/issues/detail?id=528), i try to remove the
history support in the Showcase.java > History,addValueChangeHandler
(historyHandler), it popop up more error, so i give up this method.

Therefore, can someone give me guidance about this issue. Thanks in
advance.

Trevis

unread,
Jul 29, 2009, 1:05:32 PM7/29/09
to Google Web Toolkit
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)

Trevis

Simon

unread,
Jul 29, 2009, 9:31:35 PM7/29/09
to Google Web Toolkit
Hi Trevis, thanks for reply. I need help urgently.

On Jul 30, 1:05 am, Trevis <trevistho...@gmail.com> 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


Reply all
Reply to author
Forward
0 new messages