2008/8/27 Jeromy Evans <[EMAIL PROTECTED]> > There is something else at play here. If you put a break-point in the > interceptor it should become clear. > > I vaguely an update or concern recently relating to automatic refreshing of > the model in the ModelDriven interceptor; the interceptor gets the model and > re sets it on the stack when it thinks it should. There was a concern about > it corrupting the stack order... or something... Maybe it's broken as a > result of that change. Sorry I can't be more specific but it'll show up in > struts-dev or struts-jira if you search around those terms. >
Jeromy, I have never used the "pre-result" interceptors, therefore I am not certain what I am talking about... But it seems to me that this is where the ModelDriven interceptor should direct its intervention: at some point after the execute() method and before the result is generated. (Sorry if I am out of line on this: I really have no experience with the "pre-result" concept.) * * * On a side note, I am quite fond of the prepare() method, and so, in general, I would have no objection to populating my model inside there rather than inside the execute() method. However, I just came across one situation where doing so is problematic. This is the case where I use a "StringToHibernateEntityConverter". Say, I have a "region" parameter that will be converted into the corresponding Region entity. For instance, the StringToRegionEntityConverter will convert "23" into: (Region) regionDao.load(Integer.parseInt("23")) (That's Hibernate lazy-loading at work.) Now that's a very neat way of using Entity getters and setters inside the action. The problem is that the converter yields a lazy uninitialized entity. If, somehow, my entity must end up as part of the Model, it will have to be properly initialized by the appropriate service beforehand. It would be tempting to do so inside the prepare() method: public void prepare() { regionService.initialize(region); } However, because the Parameter interceptor will re-set the region parameter after the prepare() method, the initialization of the "Region" entity will be undone because a lazy-loaded un-initialized entity will be applied on top of it! If I nonetheless wish to stick with the prepare() method, I have to tweak the setters a little: @TypeConversion(converter = "stringToRegionConverter") public void setRegion(Region region) { if (this.region == null) this.region = region; }