English 中文(简体)
GWT 形式投入领域没有价值
原标题:GWT Form input field does not have value
  • 时间:2011-11-19 17:56:17
  •  标签:
  • forms
  • gwt

I ve got a weird problem with GWT and HTML forms.
I ve made a simple FormPanel with 3 basic elements in it: FileUpload for image uploading, TextBox for the name of the image and Button for submit. Everything works (I can save the image server-side at least) except that whatever I type in the input field, it does not have a value, i.e. in Chrome s Inspect Element I clearly see that it has no value="..." field.

Why is this happening and how do I fix it? I can t save the name if it doesn t have any.
Edit:

private final FlowPanel imagePanel = new FlowPanel();
private final FormPanel form = new FormPanel();
private final FileUpload fileUpload = new FileUpload();
private final Button submitButton = new Button("Upload");
private final TextBox fileName = new TextBox();
private final HorizontalPanel hp = new HorizontalPanel();
private final VerticalPanel vp = new VerticalPanel();

public void onModuleLoad()
{
    vp.add(fileUpload);
    hp.add(fileName);
    hp.add(submitButton);
    vp.add(hp);
    form.add(vp);

    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);
    form.setAction("/upload");

    fileUpload.setName("upload"); // image identifier, used in upload handler

    fileName.setName("fileName");
    fileName.setValue("Enter file name");
    fileName.setMaxLength(40);
    fileName.addStyleName("fileNameHint");

    RootPanel.get("uploadBar").add(form);
    RootPanel.get("thumbnails").add(imagePanel);
}

这是除活动处理者外的所有布局。 提交文件时发生的所有情况都是对文件上载价值进行检查,以便允许文件延期。

问题回答

同样,我问题的根源是,我很快称之为形式。 请注意,投入领域将是形式的目标,提交书和形式。 因此,还将把文本Box作为表格寄出,如果你要求重整,就会漏掉。

。 规定<代码> 价值/代码>的财产(在控制中以图表或互用)不改变要素的属性。

If you want to see the element s current value in Chrome s Developer Tools, select it in the "Elements" pane (it s already selected if you use the "Inspect element" context menu item) and type $0.value in the JavaScript console.





相关问题
C# Form Problem: new form losing control and randomly hiding

I m encountering strange behavior with forms on a c# 3.5 app. On a button click, my form1 hides itself, creates a new form2, and shows form2. Form1 also contains the event method triggered when ...

TCPlistener.BeginAcceptSocket - async question

Some time ago I have payed to a programmer for doing multithread server. In the meantime I have learned C# a bit and now I think I can see the slowndown problem - I was told by that guy that nothing ...

RoR: before_save on nested object in form?

I have a form with a nested object (customer < order), and it works except that it keeps creating a new customer record. I d like to have it check to see if an existing customer is already ...

Receive POST from External Form

I have a form on another website (using a different backend) that I want to be able to POST to my Rails application (on a different domain). How do I generate a valid authenticity token for the ...

Getting posted values in MVC PartialView

I ve created a PartialView which I render with Html.RenderPartial, passing the name of the view and the strongly-typed data item to bind to (below): <% Html.RenderPartial("...

Recaptcha - Form Customization

Does anyone know if recaptcha can be fully customize without the default frame. I need the recaptcha image to only be a certain width as well as the input field. Has anyone done this before with ...

Better way to retain form data on manual back redirect?

I have a form that, on submit, requires the customer to look over the data, and then confirm the changes before saving the data. However, I m using a really rough way of retaining data if the user ...

热门标签