Announcement Announcement Module
No announcement yet.
Difference data binding strategy on difference scenario Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Difference data binding strategy on difference scenario

    I have an entity which is UserAccount with the following fields: username, password, fullname, email.

    And in difference scenario below, I would like to have difference data binding rule:
    1. Administrator would like to update UserAccount data: all the field allow to update => Data Binding supports for all fields
    2. User update their own account: All the field allow to update except the username => Data Binding should bind all the field except the username field, even if user use something like FireBug to edit the client side HTML to add in the username field.

    I know that we can have several Object, each for a scenario, then populate it to the entity. But it looks weird and not straight forward.

    Beside Java/Spring, I working with Yii (PHP), it have this mechanism, please take a look at the 'on' attribute from the link below

    With the above mechanism, my code to data binding is
    PHP Code:
    $model = new UserAcount($scenario); // Create empty data model with scenario specified
    $model->attributes $_POST['UserAccount']; // Data binding occurred 
    The code to data binding is same for all my action, the only difference is the $scenario value.

    With this mechanism, not only data binding but also the validator is scenario specific and centralized in the entity.

    Do we have the similar mechanism in Spring?