Announcement Announcement Module
Collapse
No announcement yet.
Having add and edit functionalities in same page using SimpleFormController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Having add and edit functionalities in same page using SimpleFormController

    Hi All,

    I am successful in implementing Add and Listing functionality using SimpleFormController.

    Now i want to have both Add and Edit functionality in same page.
    So on click of customer name in listing page, i am calling one javascript method and adding customer id to hidden parameter and submitting the listing form with action "customerAdd.do".

    Controller for this action is SimpleFormController and i am having formBackingObject method like this:

    protected Object formBackingObject(HttpServletRequest request) throws Exception
    {
    CustomerGeneral customerGeneral = new CustomerGeneral();

    String custId = request.getParameter("customerId")!=null?request.g etParameter("customerId"):"";

    if(!custId.equals(""))
    {
    CrmCustomer crmCust = customerService.getCRMCustomer(custId);
    System.out.println("Inside formBackingBean of Customer Add :: " + custId);
    customerGeneral.setFirstName(crmCust.getIfwContact s().getFirstname());
    }

    return customerGeneral;
    }

    The problem is:

    When i have "customerAdd.do" as a GET action (when i have a link with href="customerAdd.do" and clicking the link), my add page comes without any validation done. But when i submit the list page with action "customerAdd.do" as a POST method i will get my add page with validation done. So if i am not populating my "Last Name" filed to my command (as i did for firstname in formBackingObject method), i will get validation error message to the field.

    I tested with some sysouts in all my overrided methods (referenceData, formBackingObject, initBinder, onSubmit). Apart from onSubmit method all other sysouts are displaying.

    So i want to know what is the behavior of formBackingObject method. And how can i prevent for not validating my fields in this situation?

    Please help me!!!

  • #2
    You can override isFormSubmission which will tell the workflow to call formBackingObject or not.

    Comment

    Working...
    X