Anyone?

> Before I even start on my questions, lets describe a little bit about what
>  i'm doing.
> 
> Basically my model has a Region and a School.  A School _must_ belong to
>  one (and only one) Region.  What I am trying to do is create a
>  RegionPickList.  So that on the School form, you can click a link/image,
>  have a window pop up, select/search/etc a Region, Click ok and have the
>  correct information populated on the School form.  I want to do this on
>  many entities, against many entities e.g. a Region has parent Region ( in
>  fact I want to do something similar with "multi-valued" associations ).
> 
> Now what this looks like at the moment on the form is pretty much
> 
> <li>
>         <appfuse:label styleClass="desc" key="school.region"/>
>         <form:errors path="region" cssClass="fieldError"/>
>         <input type="hidden" id="regionId" name="regionId"
> value="${school.region.id}">
>         <input type="text" id="regionName" class="text medium"
> disabled="disabled" value="${school.region.name}">
>         <a
> href="/regionsPickList.html?valueField=regionId&displayField=regionName"
> target="_blank">Pick</a>
>     </li>
> 
> ugly, but it works so far.
> 
> Now,  in the controller
> 
> String regionId = request.getParameter("regionId");
> if (regionId != null) {
>       try {
>                 long id = Long.parseLong(regionId);
> 
>                 Region r = regionManager.get(id);
>                 if (r == null) {
>                       // really should be returning a error here.
>                       return new ModelAndView();
>                 }
>       catch (Exception e) {
>               //and here
>       }
> } else { /* and here */ }
> 
> Now what I really want to do ( and hopefully this is obvious by now ) is
> return validation errors.
> 
> So far I believe there are actually 2 ways I might possibly do this.  One
>  is call errors.rejectValues which I have played with and failed, the other
>  is to override initBinder and register a binder.
> 
> In this case,  which would be better to do?
> 
> In the first case I have been trying to do
> 
> errors.rejectValue("region", getText("errors.required", "school.region",
> request.getLocale()));
> return new ModelAndView().addObject(school);
> 
> but this never seems to actually work.  Any ideas?
> 
> Also it would be nice if I could add the required part of the validation to
> validation.xml.  Is that possible?  Im not really sure when (or what) the
> validation is run against yet.
> 
> Does anyone have a nice overall solution to a issue like this.
> 
> Thanks, I look forward to your thoughts and ideas.
> 
> Alistair.
> 
> ps.  Thanks to Matt Raible and everyone else who has created AppFuse.  very
> cool, very well done.
> pss.  This is my first semi-serious attempt to learn
>  Servlets/Jsp/Java/Spring MVC/etc/etc.  Please keep that in mind.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
> For additional commands, e-mail: users-h...@appfuse.dev.java.net
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Reply via email to