Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3404700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:24:54+00:00 2026-05-18T05:24:54+00:00

I have a page that has a form on it where the user can

  • 0

I have a page that has a form on it where the user can save or delete a bean. The form backing object has a bean as its property. When the user chooses to delete a bean, there’s no need to bind the bean since JPA only requires the id of the bean to be deleted.

Is there anyway to tell the Spring MVC not to bind some of the properties of a form backing object under certain conditions? I’d like to skip the binding of its bean property if the request is for delete.

EDIT: I’m using Spring 3. Here’s the psuedo code.

@Controller
public class FormController {
    @RequestMapping(method = RequestMethod.POST)
    public void process(HttpServletRequest request) {
        String action = request.getParameter("action");

        if (action.equals("SAVE")) {
            // bind all parameters to the bean property of the FormObject
        }
        else if (action.equals("DELETE")) {
            // skip the binding. manually read the bean.id parameter.
            int id = Integer.valueOf(request.getParameter("bean.id"));
            EntityManager entityManager = ...
            Bean bean = entityManager.getReference(Bean.class, id);
            entityManager.remove(bean);
        }
    }

    public class Bean {
        private int id;
    }

    public class FormObject {
        private Bean bean;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:24:55+00:00Added an answer on May 18, 2026 at 5:24 am

    You can distinguish between different submit buttons using their name attribute and route requests initiated by these buttons to different handler methods using params attributes of @RequestMapping. For example, in Spring 3:

    <input type = "submit" name = "saveRequest" value = "Save" />
    <input type = "submit" name = "deleteRequest" value = "Delete" />
    

    .

    @RequestMapping(value = "/foo", method = RequestMethod.POST, 
        params = {"saveRequest"})
    public String saveFoo(@ModelAttribte Foo foo, BindingResult result) { ... }
    
    // Only "id" field is bound for delete request
    @RequestMapping(value = "/foo", method = RequestMethod.POST, 
        params = {"deleteRequest"})
    public String deleteFoo(@RequestParam("id") long id) { ... }
    

    A more “RESTful” approach would be to put different submit buttons into different forms with method = "PUT" and method = "DELETE" and distinguish requests by method (though it requires a workaround with HiddenHttpMethodFilter).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which displays a form that a logged-in user can use
If I have a control on a page that has its Datasource set to
I have a multi-step form and user can navigate to any page to modify
In my web application I have a user profile page. That page has these
I have a page that has an iframe From one of the pages within
I have a Page that has a single instance of a UserControl that itself
In a web application, I have a page that contains a DIV that has
We have a page that ordinarily has two elements arranged side-by-side. Despite exploring a
I have a login page that has several textboxes on the page, one of
On my C# asp.net webform I have a search page that has roughly 20

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.