Okay, figured that one out. When you bind a factor to a given type, for
some other purpose, it is used every time that object needs to be injected,
whether it's at a time you wanted or not.
So, how do you ask the system to continue resolving, if your factory
doesn't want to provide an instance?
Namely, I have this little bit, where I'm playing around with injection
resolvers. Can I get a "null" MyModel to be further instantiated by the
system, so that any necessary injections can occur? That is to say replace
the new MyModel() with a call to the system to try other resolvers.
public ApiKeys.MyModel provide()
{
final HttpSession session = request.getSession();
ApiKeys.MyModel model =
(ApiKeys.MyModel) session.getAttribute("model");
// session.removeAttribute("model");
if (model == null)
{
model = new ApiKeys.MyModel();
}
return model;
}
On Mon, Apr 18, 2016 at 12:30 AM, Trenton D. Adams <
trenton.d.adams_at_gmail.com> wrote:
> @BeanParam doesn't appear to work. In debug mode,
> request.getParameter("keyId") returns the parameter value as expected, same
> for verificationCode. What am I missing, if anything? According to the
> jersey docs, and the javadoc for BeanParam, I see nothing wrong...
>
>
> https://jersey.java.net/apidocs-javax.jax-rs/2.0.1/javax/ws/rs/BeanParam.html
>
> @GET
> @Produces(MediaType.TEXT_HTML)
> @Template(name = MainView.INDEX_JSP)
> public Response postService(@BeanParam final MyModel myModel)
> throws URISyntaxException
> {
> final URI targetURIForRedirection = new URI(
> serviceUri.getBaseUri().toString() + "api-keys");
> myModel.setPage(ApiKeys.API_KEYS_JSP);
> session.setAttribute("model", myModel);
> session.setAttribute("apiKey", myModel);
>
> return Response.seeOther(targetURIForRedirection).build();
> }
>
>
> @XmlRootElement
> public static class MyModel extends PageModel
> {
> @QueryParam("keyId")
> String keyId;
>
> public String getKeyId()
> {
> return keyId;
> }
>
> @QueryParam("verificationCode")
> String verificationCode;
>
> public String getVerificationCode()
> {
> return verificationCode;
> }
>
> public MyModel()
> {
> }
> }
>
>