struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Jones <kev.r.jo...@gmail.com>
Subject Strang issue with NamedVariablePatternMatcher
Date Thu, 22 Jul 2010 11:31:03 GMT
I'm using Struts2, REST with the Convention plugin and the
NamedVariablePatternMatcher along with some code that Jeromy Evans
provided for a "HierarchicalRestActionMapper" and all my controllers
are model driven. This nearly all works!

Let's say I'm building a blog so I want URLs like /blogs/1/posts to
get all the posts for blog 1. To set this up I have a BlogsController
and a PostsController. The PostsController looks like this

@ParentPackage("default")
@Namespace("/blogs/{blogId}")
public class PostsController implements ModelDriven<Object>
{
	private String				id;
	private Integer				blogId;
	private List<Object>		        posts; // = new List<Object>()
	SinglePostViewModel			postVM	= new SinglePostViewModel();

	public void setId(String id)
	{
		this.id = id;
	}

	public void setBlogId(Integer blogId)
	{
		this.blogId = blogId;
	}

	public Object getModel()
	{
		return posts != null ? posts : postVM;
	}

	public String index(){}

	public String editNew(){}

	public String create()	{}
}

If I browse to http://.../blogs/1/posts then I see odd behaviour

If getModel returns a List<Object> then setBlogId is called, however
if getModel returns null or a postVM object then setBlogId is never
called.

I'm hoping somebody has seen this before and can point me in the right
direction.

Thanks,

-- 
Kevin

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message