Announcement Announcement Module
No announcement yet.
I am confused by how to bind to complex objects Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • I am confused by how to bind to complex objects

    I am confused by how to bind to complex objects!!

    Take for example, I have a form for editing private messages in between users.

    So, lets assume

    id Long
    User from
    User to
    String subject
    String message

    How exactly would I go about dealing with the user objects? ie. I want a User submitting to be able to enter in a string representation of the Username. If they submit, and the user doesn't exist in the database, I'd obviously like to let them know the user doesn't exist and repost the error with all the form data entered. I've read through the forum and read something about PropertyEditors, but there doesn't seem to be a real guide anywhere to go about doing this.

    I would imagine, I need to grab the username, call a lowerlevel method checking if the username exists in the database,but I'm at a loss for what to put in my jsps and where to put this logic in the FormController.

    Any help would be greatly appretiated.

    ..jordan willms

  • #2
    Re: I am confused by how to bind to complex objects

    allright. So I've created a UserEditor object, and also a group object (because in my system a private message can also be directed to a group).

    A new problem has unfolded.

    Basically, I need to make some of the fields optional to bind to. Ie. there is a group field, and a user field (for username or groupname). Only one of either should be filled in.

    Currently, both need to be filled in to get even have the ability to save (because I get init binding errors since one is empty).

    The solution I really want, is a single text form field, where a visitor can either enter a username OR a groupname, and the Form figures out which (if any) match the database, and submits it if it does, or presents nice error messages ("Could not find a matching User or Group")

    Any advice? I'm a little lost here!