Hello again Yee,
Here's a more concrete example following up on what I described previously :
// JPA annotations left out for clarity
public class User extends IUser {
private Long id;
private String name;
// ...
}
@StrictBinding
public class ActionExample extends BaseActionBean {
@ValidateNestedProperties({
@Validate(field="name"),
})
private User user;
@SpringBean
private IServiceUser serviceUser;
@HandlesEvent(value="save")
public Resolution save() {
serviceUser.persist(user);
return new ForwardResolution("/confirmSave.jsp");
}
// ...
}
@Service
public class ServiceUser implements IServiceUser {
@Autowired
private IDaoUser daoUser;
public void persist(User user) {
daoUser.persist(user);
}
// ...
}
@Repository
public class DaoUser extends Dao<User, Long> implements IDaoUser {
// persist(User) is inherited from Dao<T, PK>
}
http://www.stripesframework.org/display/stripes/Stripes+Spring+JPA
Cheers,
DaveMark
--- On Mon, 22/6/09, DaveMark <[email protected]> wrote:
> From: DaveMark <[email protected]>
> Subject: RE: Danger with binding to Domain Object
> To: [email protected]
> Date: Monday, 22 June, 2009, 10:16 AM
> Hi Yee,
>
> > I have been using the binding direct
> > to domain object pattern for a while.
>
> I recently finished a large scale 3-tier project where we
> should have used Stripes and we should have used it (with
> @StrictBinding) in the way I describe in my Stripes Spring
> JPA guide here :
> http://www.stripesframework.org/display/stripes/Stripes+Spring+JPA
>
> > I am beginning to think that binding to domain
> > object maybe is not a good idea for 3 tiers
> > architecture. There is too many ways to go wrong.
> >
> > Can someone share your experience on this?
>
> With pleasure! @StrictBinding can works with @Validate to
> restrict binding only to those properties you wish to allow.
> In other words not to setId(Long)! You allow only certain
> properties to be bound then send the model object off to the
> dao layer (via the service layer) where you'd call :
> daoExample.persist(modelExample);
>
> For special cases, the annotation also supports the
> "policy," "allow," and "deny" elements. More information can
> be found in the Javadocs :
> http://stripes.sourceforge.net/docs/current/javadoc/index.html?net/sourceforge/stripes/action/StrictBinding.html
>
> Cheers,
>
> DaveMark
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
>
>
>
>
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users