On 9/6/05, Rick Reumann <[EMAIL PROTECTED]> wrote:
> 
> Craig McClanahan wrote the following on 9/6/2005 9:57 PM:
> 
> > If you use prerender() the way it's intended to be used (on the 
> destination
> > page, not the origin page -- and not trying to share them across multple
> > pages) you'll quickly discover that you really do want it called every 
> time.
> 
> Ok, let me try to be more clear. For example, lets have "search.jsp"
> 
> If searching for a regular employee lets have it basic - only one field
> "name" (only field you can search by).
> 
> But search.jsp can also be used to search for a "regional manager"
> (still just an employee), but for that kind of search we need to show
> the list of 'regions' in a drop down list.
> 
> Wouldn't both scenarios be backed by the same bean? If so they would
> both share the same prerender method, yet we only need the 'regions'
> populating when we had the case that we were searching for a regional
> manager.


The scenarios should be backed by the same bean *only* if they are both done 
using the same JSP page. You want a 1:1 correspondence. 

How do you get around not having some kind of logic in the prerender
> method to decide whether or not it needs to populate the 'regions' list
> for the drop down?


If you did perform both kinds of searches on the same JSP page, and 
therefore had a shared prerender() method, you would indeed need conditional 
logic inside prerender() that knew which scenario was being shown. You would 
need to pass in knowledge of that fact somehow, just like you had to pass in 
the employee id in the scenario I described.

Of course, you're going to have other conditional logic too (like, whether 
or not to render the dropdown list at all). That's the complexity price you 
pay for using the same JSP page to perform two distinct functions; 
presumably this extra complexity is worth the benefits, or you'd have used 
separate pages in the first place.

But the key principle is the 1:1 relationship between a JSP page and a 
ViewController. Otherwise, you're going against the grain that the 
ViewController architecture encourages.

--
> Rick


Craig


---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

Reply via email to