wei-spring / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

HTML Form submit not working #161

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The following xhtml MP1.0 wont work:
<form action="welcome" method="post" id="id_welcome">
      <p>
        <input type="text" id="displayname" size="15" maxlength="25" /><br />
        <input type="checkbox" id="addcontacts" /> Add people to my address book
      </p>
      <div style="text-align: right"><a href="terms.html">Terms & conditions</a></div>
      <table>
        <tr>
          <td>
            <div style="text-align: left">
              <input type="reset" value="&lt; No thanks" id="#!5" />
            </div>
          </td>
          <td>
            <div style="text-align: right">
              <input type="submit" value="Join Bozza >" id="#displayName" />
            </div>
          </td>
        </tr>        
      </table>
    </form>

Because,

void addInput(String key,Object input,String defaultValue) {
   ....
   ....
   if (key==null) {
      return; //no id
   }
   ....
}

And that returns null because,

private void handleInput(HTMLElement element,int align) {
   ....
   ....
   String name=element.getAttributeById(HTMLElement.ATTR_NAME);
   String id=element.getAttributeById(HTMLElement.ATTR_ID);
   ....
   ....
   if (curForm!=null) {
      curForm.addInput(name, cmp,value);
      textfieldsToForms.put(tf, curForm);
   }
   ....
}

As you can see my XHTML does not have the name tag, but uses the ID tag. In the 
function addInput it looks like (based on the comment // no ID) that you expect 
a ID, but in the handleInput(HTMLElement element,int align) call you pass the 
name.

I also no using "name" causes some warnings like "name not supported".

I'll use name if you want me to, but would like the clarification which one is 
really used/supported.

Original issue reported on code.google.com by jkoo...@gmail.com on 17 Apr 2012 at 1:43

GoogleCodeExporter commented 9 years ago
I would suggest you use name. The HTML component was written by Ofir who is not 
a part of Codename One, so we have limited understanding of why some choices 
were made. We generally try to change it as little as possible since most 
people will choose to use the webkit based renderer when possible. 

Original comment by shai.almog on 17 Apr 2012 at 1:51

GoogleCodeExporter commented 9 years ago
Changing my id's to name works thanks. 

I think some tags's names are supported some not. 

Original comment by jkoo...@gmail.com on 17 Apr 2012 at 1:57

GoogleCodeExporter commented 9 years ago
I notice a few things in the HTML right away that may cause issues with the 
parser and not finding tags, like the & should be encoded to &, the > in the 
input value should be encoded to >, etc.  Might want to run the html through 
validator.w3c.com and try it again.

Original comment by 1815...@coolman.ca on 18 Apr 2012 at 1:18

GoogleCodeExporter commented 9 years ago
My XHTML renders fine.

Original comment by jkoo...@gmail.com on 18 Apr 2012 at 8:17