Announcement Announcement Module
Collapse
No announcement yet.
Multiple Tables in Database to one Form Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Tables in Database to one Form

    Hi,
    I have Multiple tables
    LoginTable userid,password,active
    userTable userid,firstname,lastname,address,other info,email etc;

    I want the admin to enter userid,(set password,active of the first table,) and firstname,lastname,address etc of secondtable in single Form

    How do i bind the fields of form with tables using command class

    Thanks
    Sridhar

  • #2
    How do i bind the fields of form with tables using command class
    You bind form fields to your command object which is typically a domain object which maps to the database. That mapping can be to one or many tables depending on our ORM.

    If you need to bind to multiple domain objects, you can combine them into a single command object, and use nesting.

    See simple binding

    Comment


    • #3
      What is nesting?
      Can you post a sample code
      thanks

      Comment


      • #4
        What is nesting?
        When an object contains another obect. You can still bind to these nested objects.

        Can you post a sample code
        From the JPetstore sample:
        Code:
          <spring:bind path="accountForm.account.username">
              <input type="text" name="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>"/>
          </spring:bind>
        Code:
        public class AccountFormController extends SimpleFormController {
        ...
                setCommandName("accountForm");
        ...
        Code:
        public class AccountForm implements Serializable {
        
            private Account account;
        ...
        Code:
        public class Account implements Serializable {
        
          /* Private Fields */
        
          private String username;
        ...

        Comment


        • #5
          Thanks got it

          Comment


          • #6
            Further doubt

            Hi,
            <code>
            public class Intermediary extends com.chakra.model.BaseObject implements java.io.Serializable {


            // Fields

            private Integer id;
            private String companyName;
            private WpContact wpContact = new WpContact();


            </code>

            I have class WpContact corresponding to table wp_contact

            Now what i need . I have the form which displays thee fields from wp_contact intermediary.jsp

            What things are to be done to ensure wp_contact details are also saved
            My id and companyname is saved in wp_company.

            also I have to insert into table wp_company_contact the values of
            the newly generated company id ,contact id ( i have seen appfuse example but i am missing something)

            only companyname and id gets inserted whille i lose wp_contact details

            what should i do

            thanks

            Comment


            • #7
              hi,
              I am using hibernate

              Comment


              • #8
                can you give me some more information on this...... Thanks

                Comment

                Working...
                X