[Mav-user] RedirectView#go

2003-10-27 Thread Ted Husted
On RedirectView, if the model is neither a Map nor a String, should 
model.toString() be used instead? ?

I could make the change, if we that's what we want.

And should we do nothing if the model is null (WARN in the log?), or 
just NPE?

As it stands, in the case of a null model or model!-Map  !-String, it 
appears that the original target would be added to itself!



public void go(ViewContext vctx)  throws IOException, ServletException
  {
String result = this.target;
if (vctx.getModel() instanceof Map)
{
  result = this.addQueryParams(result, (Map)vctx.getModel());
}
else if (vctx.getModel() instanceof String)
  {
 result = (String)vctx.getModel();
  }

// Now, a separate step
result = this.addQueryParams(result, vctx.getViewParams());
// Just in case we need a session id
result = vctx.getRealResponse().encodeRedirectURL(result);

vctx.getRealResponse().sendRedirect(result);
  }
	

-Ted.



---
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
[INVALID FOOTER]


RE: [Mav-user] RedirectView#go

2003-10-27 Thread Schnitzer, Jeff
The behavior is intended to allow the base path (aka target) to be
specified in the sitemap file, but also allow it to be overridden.

These are the cases:

1) User specified path in maverick.xml and that's it.

2) User specified path in maverick.xml and wants to add parameters by
setting view params.

3) User specified path in maverick.xml and wants to add parameters by
setting a Map as the model

4) User wants to override path in maverick.xml (or didn't specify it in
the first place) and sets a String as the model.  Any view params are
additionally interpreted as parameters to add.

The problem with using toString() on the model is that it would force
the user to explicitly setModel(null) for cases 1  2.

I don't think there is a problem with the original target being added to
itself... I use all of these cases myself.

Jeff


 -Original Message-
 From: Ted Husted [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 27, 2003 2:37 AM
 To: [EMAIL PROTECTED]
 Subject: [Mav-user] RedirectView#go
 
 On RedirectView, if the model is neither a Map nor a String, should
 model.toString() be used instead? ?
 
 I could make the change, if we that's what we want.
 
 And should we do nothing if the model is null (WARN in the log?), or
 just NPE?
 
 As it stands, in the case of a null model or model!-Map  !-String,
it
 appears that the original target would be added to itself!
 
 
 
 public void go(ViewContext vctx)  throws IOException, ServletException
{
  String result = this.target;
 
  if (vctx.getModel() instanceof Map)
  {
result = this.addQueryParams(result, (Map)vctx.getModel());
  }
  else if (vctx.getModel() instanceof String)
{
   result = (String)vctx.getModel();
}
 
  // Now, a separate step
  result = this.addQueryParams(result, vctx.getViewParams());
 
  // Just in case we need a session id
  result = vctx.getRealResponse().encodeRedirectURL(result);
 
  vctx.getRealResponse().sendRedirect(result);
}
 
 
 
 -Ted.
 
 
 
 
 ---
 This SF.net email is sponsored by: The SF.net Donation Program.
 Do you like what SourceForge.net is doing for the Open
 Source Community?  Make a contribution, and help us add new
 features and functionality. Click here: http://sourceforge.net/donate/
 [INVALID FOOTER]



---
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
[INVALID FOOTER]