• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTML form to form bean mapping

 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am trying to overcome a funny situation.

I have an ActionForm bean where there is a field:


In the HTML form I correspondingly have a textbox:

Upon submitting the form, I get a null value in the bean's field.

However, (this however is really very important) when I name the field in the bean as : "firstName" and correspondingly change in the HTML form to "firstName", all works like a charm.

Please help me understand what's happening.

Regards
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do your getters/setters for the two names look like?
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had changed the getters and setters accordingly while changing names.

When it was "sUserFirstName" the methods were:


Now it is "firstName" and the methods are:


I dont know if I should laugh at this problem or cry!

Regards
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Himanshu Kansal wrote:I dont know if I should laugh at this problem or cry!


You should "investigate",
Here are the steps I would followed If I came across the similar situation

  • Check if the HTML is valid, close all the tags, properly, especailly see if there is problem for "sUserFirstName" html tag
  • I would used html:text tag, instead of plain input type="text"
  • Look if you are validating "sUserFirstName" field, which consequently set the "sUserFirstName" to null
  • Finally, any exception/error in log file


  • And the best one is to go with "firstName" instead of "sUserFirstName"
  •  
    Himanshu Kansal
    Ranch Hand
    Posts: 257
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Check if the HTML is valid, close all the tags, properly, especailly see if there is problem for "sUserFirstName" html tag


    would not make a difference in changing names.

    I would used html:text tag, instead of plain input type="text"


    I prefer going with the original. No good reason to replace the standard just because an alternative is available.

    Look if you are validating "sUserFirstName" field, which consequently set the "sUserFirstName" to null


    Not as yet. Will move to validating, that to client side, only after I get over with this.

    Finally, any exception/error in log file


    Nah, none.

    These steps are just intuitive basics and everyone does them. I am making some beautiful mistake which would make me look stupid later.

    And the best one is to go with "firstName" instead of "sUserFirstName"


    I fear that

    Can't figure out the difference in "sUserFirstName" and "firstName".

    Regards
     
    Sagar Rohankar
    Ranch Hand
    Posts: 2908
    1
    Spring Java Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Himanshu Kansal wrote:

    And the best one is to go with "firstName" instead of "sUserFirstName"


    I fear that


    Why

    Then, I would use this hack, if that's OK to you ?


     
    Himanshu Kansal
    Ranch Hand
    Posts: 257
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Just giving a reason because you asked for it. I have no justifications:

    "My employer wants variable names to present like that(MS notation). Any variable, anywhere"

    Anyways, I am quitting next month. :p

    Regards
     
    Sagar Rohankar
    Ranch Hand
    Posts: 2908
    1
    Spring Java Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Himanshu Kansal wrote:"My employer wants variable names to present like that(MS notation). Any variable, anywhere"


    That's ridicules , man !! Don't they know there is something called as "Java Coding Standards"

    Himanshu Kansal wrote:Anyways, I am quitting next month. :p


    Good Luck for future

    And as per the problem, try using different name like "sFirstName" or something like that. HTH
     
    Forget Steve. Look at this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic