views:

275

answers:

2

Well its simple, Basically I want to follow GWT's "One Page" paradigm and yet integrate Spring security into the application. What i understand that if the cookie is not found in the system, spring will redirect user to a Open id referrer page asking for login else it would simply send my server the user's open url id.

This is what i trid in GWT:

        final FormPanel formPanel = new FormPanel();
        RootPanel.get("openId").add(formPanel);
        VerticalPanel openIdContainer = new VerticalPanel();
        formPanel.add(openIdContainer);

        TextBox url = new TextBox();
        url.setText("https://www.google.com/accounts/o8/id");
        url.setName("j_username");
        openIdContainer.add(url);

        formPanel.setAction("j_spring_openid_security_check");
        formPanel.setMethod(FormPanel.METHOD_POST);

        Button btn = new Button("Open ID");
        btn.addClickListener(new ClickListener() {
            public void onClick(Widget sender)
            {
                formPanel.submit();
            }
        });
        openIdContainer.add(btn);        

        formPanel.addFormHandler(new FormHandler() {
            public void onSubmit(FormSubmitEvent event)
            {
                System.out.println("On Submit invoked " +event.isCancelled());
            }
            public void onSubmitComplete(FormSubmitCompleteEvent event)
            {
                System.out.println("On Submit Complete invoked " + event.toString());
            }

        });

corresponding output : On Submit invoked false On Submit Complete invoked null

As I understand, the html received is null. How else should I do it ? GWT 1.5 does not have a simple form (one that indeed refreshes the page on submit) and an input tag with the type as submit. Will i have to hard code this into HTML widget ? I tried setting another frame as this form panel's target but still unable to get any fruitful results.

A: 

As far as I can tell you are not setting the correct upload URL:

formPanel.setAction(uploadServiceUrl);

/**
   * Sets the 'action' associated with this form. This is the URL to which it
   * will be submitted.
   * 
   * @param url the form's action
   */
  public void setAction(String url) {
    getFormElement().setAction(url);
  }
Drejc
please clarify, do you mean that "j_spring_openid_security_check" as my form's action is not right ? its a standard spring security target url post. I doubt its wrong.
Salvin Francis
I'm not familiar with Spring or OpenId, but I doubt that GWT is posting this to the correct URL. Check with FireBug where your POST request goes to and what is actually send.
Drejc
A: 

Check out my blogpost where I describe your scenario (including sample sourcecode).