Re: Wicket 1.5 - Generic JSON Response

2012-09-27 Thread oggie
Ahijah wrote
 
 Martin Grigorov-4 wrote
 On Thu, Apr 12, 2012 at 7:38 AM, Ahijah lt;

 darren.greer@

 gt; wrote:
 
 mountResource(/Feed2, new MyResourceReference());
 
 class MyResourceReference extends ResourceReference {
   public IResource getResource() { return new MyResource(); }
 }
 Thanks Martin!  For everyone else's reference, the final code that is
 working looks like this:
 
 --Feed.class
 public class Feed extends AbstractResource {
   
   private static final long serialVersionUID = 1L;
   
   protected ResourceResponse newResourceResponse(Attributes a) { 
   ResourceResponse r = new ResourceResponse(); 
   r.setContentType(application/json);
   r.setWriteCallback(new WriteCallback() { 
   public void writeData(Attributes a) { 
   
 a.getResponse().write([{\id\:111,\title\:\MainEvent\,\start\:\2012-04-10T07:00:00\,\end\:\2012-04-10T09:30:00\,\url\:\?EventID=111\,\allDay\:false}]);
 } 
   }); 
   return r; 
   } 
 
 }
 ---End Feed.class--
 
 --Application.class
   @Override
   protected void init() {
   super.init();   
   mountResource(/Feed, new FeedReference());
   }
 
   public class FeedReference extends ResourceReference { 
   public FeedReference() {
   super(FeedReference.class, feed);
   }
   public IResource getResource() { return new Feed(); } 
   } 
 ---End Application.class-

Is there any way to tie this to the standard wicket security model? Right
now, our web pages are all annotated with @AuthorizeInstantiation(admin),
so how would we be able to apply it to this scenario?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4652432.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket 1.5 - Generic JSON Response

2012-09-27 Thread Martin Grigorov
IAuthorizationStrategy is not used for IResource at the moment.
You need to roll something yours for this check.

On Thu, Sep 27, 2012 at 3:37 PM, oggie gog...@gmail.com wrote:
 Ahijah wrote

 Martin Grigorov-4 wrote
 On Thu, Apr 12, 2012 at 7:38 AM, Ahijah lt;

 darren.greer@

 gt; wrote:

 mountResource(/Feed2, new MyResourceReference());

 class MyResourceReference extends ResourceReference {
   public IResource getResource() { return new MyResource(); }
 }
 Thanks Martin!  For everyone else's reference, the final code that is
 working looks like this:

 --Feed.class
 public class Feed extends AbstractResource {

   private static final long serialVersionUID = 1L;

   protected ResourceResponse newResourceResponse(Attributes a) {
   ResourceResponse r = new ResourceResponse();
   r.setContentType(application/json);
   r.setWriteCallback(new WriteCallback() {
   public void writeData(Attributes a) {

 a.getResponse().write([{\id\:111,\title\:\MainEvent\,\start\:\2012-04-10T07:00:00\,\end\:\2012-04-10T09:30:00\,\url\:\?EventID=111\,\allDay\:false}]);
 }
   });
   return r;
   }

 }
 ---End Feed.class--

 --Application.class
   @Override
   protected void init() {
   super.init();
   mountResource(/Feed, new FeedReference());
   }

   public class FeedReference extends ResourceReference {
   public FeedReference() {
   super(FeedReference.class, feed);
   }
   public IResource getResource() { return new Feed(); }
   }
 ---End Application.class-

 Is there any way to tie this to the standard wicket security model? Right
 now, our web pages are all annotated with @AuthorizeInstantiation(admin),
 so how would we be able to apply it to this scenario?



 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4652432.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket 1.5 - Generic JSON Response

2012-09-27 Thread oggie
Any suggestions on how I might roll my own? I tried a few things like
injecting the Feed class and annotating it, but I suspect it's too late at
that point.




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4652442.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket 1.5 - Generic JSON Response

2012-09-27 Thread Martin Grigorov
There is no code in Wicket that will check for this annotation in
non-Component classes.

On Thu, Sep 27, 2012 at 4:17 PM, oggie gog...@gmail.com wrote:
 Any suggestions on how I might roll my own? I tried a few things like
 injecting the Feed class and annotating it, but I suspect it's too late at
 that point.




 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4652442.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket 1.5 - Generic JSON Response

2012-04-12 Thread Martin Grigorov
On Thu, Apr 12, 2012 at 7:38 AM, Ahijah darren.gr...@gmail.com wrote:
 Thanks for the tip, that definitely sounds like the way to go.  Quick
 follow-up, how does one mount an AbstractResource within the application.
 There doesn't appear to be an Abstract reference class to instantiate using
 something like:

 mountResource(/Feed2, new ResourceReference(Feed2.class));

mountResource(/Feed2, new MyResourceReference());

class MyResourceReference extends ResourceReference {
  public IResource getResource() { return new MyResource(); }
}


 Thanks again!

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4550948.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket 1.5 - Generic JSON Response

2012-04-12 Thread Ahijah

Martin Grigorov-4 wrote
 
 On Thu, Apr 12, 2012 at 7:38 AM, Ahijah lt;darren.greer@gt; wrote:
 
 mountResource(/Feed2, new MyResourceReference());
 
 class MyResourceReference extends ResourceReference {
   public IResource getResource() { return new MyResource(); }
 }
 

Thanks Martin!  For everyone else's reference, the final code that is
working looks like this:

--Feed.class
public class Feed extends AbstractResource {

private static final long serialVersionUID = 1L;

protected ResourceResponse newResourceResponse(Attributes a) { 
ResourceResponse r = new ResourceResponse(); 
r.setContentType(application/json);
r.setWriteCallback(new WriteCallback() { 
public void writeData(Attributes a) { 

a.getResponse().write([{\id\:111,\title\:\MainEvent\,\start\:\2012-04-10T07:00:00\,\end\:\2012-04-10T09:30:00\,\url\:\?EventID=111\,\allDay\:false}]);
} 
}); 
return r; 
} 

}
---End Feed.class--

--Application.class
@Override
protected void init() {
super.init();   
mountResource(/Feed, new FeedReference());
}

public class FeedReference extends ResourceReference { 
public FeedReference() {
super(FeedReference.class, feed);
}
public IResource getResource() { return new Feed(); } 
} 
---End Application.class-

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4551752.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket 1.5 - Generic JSON Response

2012-04-12 Thread Andrew Geery
If you have a number of JSON end-points, the best architecture would
probably be to use Spring MVC to do the JSON handling, and then map the
Spring MVC paths into your web app using the Wicket filter ignore paths
option (
https://cwiki.apache.org/WICKET/best-practices-and-gotchas.html#BestPracticesandGotchas-
).

Thanks
Andrew

On Thu, Apr 12, 2012 at 8:47 AM, Ahijah darren.gr...@gmail.com wrote:


 Martin Grigorov-4 wrote
 
  On Thu, Apr 12, 2012 at 7:38 AM, Ahijah lt;darren.greer@gt; wrote:
 
  mountResource(/Feed2, new MyResourceReference());
 
  class MyResourceReference extends ResourceReference {
public IResource getResource() { return new MyResource(); }
  }
 

 Thanks Martin!  For everyone else's reference, the final code that is
 working looks like this:

 --Feed.class
 public class Feed extends AbstractResource {

private static final long serialVersionUID = 1L;

 protected ResourceResponse newResourceResponse(Attributes a) {
 ResourceResponse r = new ResourceResponse();
r.setContentType(application/json);
r.setWriteCallback(new WriteCallback() {
public void writeData(Attributes a) {


 a.getResponse().write([{\id\:111,\title\:\MainEvent\,\start\:\2012-04-10T07:00:00\,\end\:\2012-04-10T09:30:00\,\url\:\?EventID=111\,\allDay\:false}]);
 }
});
return r;
}

 }
 ---End Feed.class--

 --Application.class
@Override
protected void init() {
super.init();
mountResource(/Feed, new FeedReference());
}

public class FeedReference extends ResourceReference {
public FeedReference() {
super(FeedReference.class, feed);
}
public IResource getResource() { return new Feed(); }
}
 ---End Application.class-

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4551752.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Wicket 1.5 - Generic JSON Response

2012-04-11 Thread Ahijah
I've been working on various implementations of this all day, to try and
output a simple JSON response, as Content-Type: application/json, with
absolutely no luck.  My current class is setup as below.  However, when
sending a request to the Feed URL, it comes back as text/plain, with the
JSON formatted string embedded below.  What am I doing wrong?  Thanks.

-
public class Feed extends WebPage implements IMarkupResourceStreamProvider {

private static final long serialVersionUID = 1L;

@Override 
protected void configureResponse(WebResponse response) { 
super.configureResponse(response); 
response.setContentType(application/json); 
response.addHeader(Content-Type, application/json);
} 

@Override 
public void renderPage() { 
   
getResponse().write([{'id':111,'title':'MainEvent','start':'2012-04-10T07:00:00','end':'2012-04-10T09:30:00','url':'?EventID=111','allDay':false}]);
 
} 

public IResourceStream getMarkupResourceStream(MarkupContainer 
container,
Class? containerClass) { 
return new StringResourceStream(); 
} 

}

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4550807.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket 1.5 - Generic JSON Response

2012-04-11 Thread Dan Retzlaff
Hi, Ahijah. I think you should use a resource for this, not a page.
Something like:

class MyResource extends AbstractResource {
  ResourceResponse newResourceResponse(Attributes a) {
ResourceResponse r = new ResourceResponse();
r.setContentType(application/json);
r.setWriteCallback(new WriteCallback() {
  public void writeData(Attributes a) {
a.getResponse().write(your json here); }
});
return r;
  }
}

On Wed, Apr 11, 2012 at 8:38 PM, Ahijah darren.gr...@gmail.com wrote:

 I've been working on various implementations of this all day, to try and
 output a simple JSON response, as Content-Type: application/json, with
 absolutely no luck.  My current class is setup as below.  However, when
 sending a request to the Feed URL, it comes back as text/plain, with the
 JSON formatted string embedded below.  What am I doing wrong?  Thanks.

 -
 public class Feed extends WebPage implements IMarkupResourceStreamProvider
 {

private static final long serialVersionUID = 1L;

@Override
protected void configureResponse(WebResponse response) {
super.configureResponse(response);
response.setContentType(application/json);
response.addHeader(Content-Type, application/json);
}

@Override
public void renderPage() {


 getResponse().write([{'id':111,'title':'MainEvent','start':'2012-04-10T07:00:00','end':'2012-04-10T09:30:00','url':'?EventID=111','allDay':false}]);
}

public IResourceStream getMarkupResourceStream(MarkupContainer
 container,
 Class? containerClass) {
return new StringResourceStream();
}

 }

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4550807.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Wicket 1.5 - Generic JSON Response

2012-04-11 Thread Ahijah
Thanks for the tip, that definitely sounds like the way to go.  Quick
follow-up, how does one mount an AbstractResource within the application. 
There doesn't appear to be an Abstract reference class to instantiate using
something like:

mountResource(/Feed2, new ResourceReference(Feed2.class));

Thanks again!

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Generic-JSON-Response-tp4550807p4550948.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org