juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Bognar <jamesbog...@apache.org>
Subject Re: Quick yet powerful techniques for customizing HTML serialization
Date Mon, 17 Jul 2017 15:23:25 GMT
I'm on vacation this week so my replies may be scarce.

Some thoughts....

1) We do have the HtmlRender class that allows POJOs to be serialized as
custom HTML (typically HTML5 beans).  Maybe this could be extended for
particular frameworks?

2) It's definitely possible to define POJOs that get swapped to HTML5 bean
constructs.  e.g. A MyForm bean that gets swapped with a populated Form
object.


On Mon, Jul 17, 2017 at 7:59 AM sblackmon <sblackmon@apache.org> wrote:

> Just wanted to share that embedding widgets in inherited header and
> footer, and as menu items, is really helping to make s site I’m working on
> look and feel like an application rather than a bunch of pages.
>
> I’m interested in render certain pojo types using non-standard (but common
> throughout the application) HTML fragments. Obviously this can be done in
> pure java on a class-by-class basis, but maybe we should consider framework
> support for something like handlebars or freemarker to address this
> use-case?
>
> Basically HTML serializer could support binding a specific POJO class to a
> template resource file on the classpath, written in a standard templating
> language rather than plain java.
>
> Any thoughts?
> On July 10, 2017 at 1:47:41 PM, sblackmon (sblackmon@apache.org) wrote:
>
> Perfect.  Thanks!
>
>
> On July 10, 2017 at 1:22:58 PM, James Bognar (jamesbognar@gmail.com)
> wrote:
>
> You can do that today!
>
> @RestResource(
> htmldoc=@HtmlDoc(
> widgets={
> MyHeader.class
> },
> header={
> "$W{MyHeader}"
> }
> )
> )
>
> Then your widget can be defined to load from resources.
>
> public class MyHeader extends Widget {
> @Override
> public String getScript(RestRequest req) throws Exception {
> return loadScript("MyHeader.js");
> }
> @Override
> public String getStyle(RestRequest req) throws Exception {
> return loadStyle("MyHeader.css");
> }
> @Override
> public String getHtml(RestRequest req) throws Exception {
> return loadHtml("MyHeader.html");
> }
> }
>
> The loadX() methods strips off comments (e.g. apache license headers) from
> the files for you.
>
> You can embed any of the various other variables inside the files as well
> (e.g. $L{}, $R{}, etc....) since the $W variables are recursively resolved
> (just like any other variable).
>
>
> On Mon, Jul 10, 2017 at 1:49 PM, sblackmon <sblackmon@apache.org> wrote:
>
> > +1 for more flexibility in the header region.
> >
> > Might it make sense to let developers put HTML with expressions in
> > separate resource files and specify the class path resource with an
> > annotation field, to make the fragments easier to re-use?
> >
> > Or perhaps support Widget classes as values for header, footer, aside,
> > etc…?
> >
> > On July 10, 2017 at 12:14:21 PM, James Bognar (jamesbognar@apache.org)
> > wrote:
> >
> > There's a change I'd like to make to the way the page header is specified
> > on the HTML views.
> >
> > It's rather complicated right now. The Title and Description in the
> header
> > is added as <h1> and <h2> tags in the HtmlDocTemplateBasic class.
> > The title comes from @HtmlDoc.title() or @RestResource.title() if not
> > specified (or the resource bundle or swagger file)
> > The description comes from @HtmlDoc.description() or
> > @RestMethod.description() if not specified (or the resource bundle or
> > swagger file).
> >
> > What I'd like to do is eliminate @HtmlDoc.title()/description()
> > /branding(),
> > and just add the following default value to the header() annotation on
> > RestServletDefault:
> > @RestResource(
> > htmldoc=@HtmlDoc(
> > header={
> > "<h1>$R{RestServlet.servletTitle}</h1>",
> > "<h2>$R{RestServlet.methodSummary}</h2>",
> > "<a href='http://juneau.apache.org'><img
> > src='$U{servlet:/htdocs/juneau.png}'></a>"
> > }
> > )
> > )
> >
> > This simplifies the logic and I believe makes it easier to understand and
> > override in subclasses.
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message