Thanks for the ideas, either one will probably work.
As a side note, I found some of the implicit viewable functionality
confusing and just thought I would share what I think would be helpful
for others.  I had annotated my implicit action with @GET, not
realizing that it would cause the implicit view not to work.  Also,
the most helpful doc I found for implicit views was
http://blogs.oracle.com/sandoz/entry/mvcj
Thanks,
Ransom
On Wed, Sep 7, 2011 at 4:25 PM, Martin Matula <martin.matula_at_oracle.com> wrote:
> ..or you can still use the implicit viewables and call the index method on
> the resource passed in ${it} from the JSP template.
>
> On 7.9.2011 16:16, Martin Matula wrote:
>>
>> Hi Ransom,
>> You can still use Viewables, just not the implicit ones. You can write a
>> code like this:
>>
>> @Path("/foo")
>> public class FooResource {
>>    @GET
>>    @Produces("application/json")
>>    public List<FooDto>  index() {
>>        FooDto foo = new FooDto();
>>        List<FooDto>  foos = new ArrayList<FooDto>();
>>        return foos;
>>    }
>>
>>    @GET
>>    @Produces("text/html")
>>    public Viewable indexHtml() {
>>        return new Viewable("index", index());
>>    }
>>  }
>>
>> Regards,
>> Martin
>>
>> On 6.9.2011 22:14, Ransom Briggs wrote:
>>>
>>> Hello,
>>>
>>> After fighting with ImplicitViewables for a morning, I'm finding that
>>> they are not really working for my use case.  What I am trying to
>>> accomplish is serving up JSON and HTML from the same action.  I am
>>> trying to keep the resources simple, so I have something like this
>>> right now, where actions return the entity that should be served as
>>> both JSON and HTML.
>>>
>>> @Path("/foo")
>>> @Produces({"application/json", "text/html"})
>>> public class FooResource {
>>>     @GET
>>>     public List<FooDto>  index() {
>>>         FooDto foo = new FooDto();
>>>         List<FooDto>  foos = new ArrayList<FooDto>();
>>>         return foos;
>>>     }
>>> }
>>>
>>> I was going to write a MessageBodyWriter that could serialize to HTML,
>>> but I could not figure out how to access the resource instance, which
>>> I need so I could use templates to defined different HTML views for
>>> different actions.  Ideally, my code would result in something like
>>> ImplicitViewables where the template would be found in
>>> FooResource/index.jsp, except instead of ${it} being the resource, it
>>> would the entity that the method returned.
>>>
>>> Thanks,
>>> Ransom
>