juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Bognar <jamesbog...@apache.org>
Subject HtmlSerializer enhancements.
Date Wed, 17 May 2017 14:47:44 GMT
I had some ideas last night for enhancing the HTML serialization support.


===== Custom renderers =====

Customize how property values are rendered by HtmlSerializer.

@HTML(render=MyHtmlRender.class)
public StatusEnum getStatus();


public class MyHtmlRender extends HtmlRender {

   // Gets applied to TD element containing field.
   @Override
   public String getStyle(Object value) {
      switch(value) {
         case(WARNING): return "background:color:yellow";
         ...
      }
   }

   // Transforms property value to something else.
   // In this case, an image.
   @Override
   public Object getContent(Object value) {
      switch(StatusEnum) {
         case(WARNING): return img().src('bad_stuff.png');
         ...
      }
   }
}

The caveat is that this would be a one-way transform (the HtmlParser would
not be able to convert this back into the original data).
But I think this would be a great new feature.  I currently use Juneau for
debugging interfaces where I want to quickly view raw data.  This would
allow me to highlight data that's outside of certain thresholds.

This only affects the HTML view.  All other serializers would show the raw
data.


===== Enhanced tables with search/view/sort links =====

One powerful existing feature many don't know about is the Queryable
converter that gets applied via @RestMethod(converters=Queryable.class).
It allows manipulation of tables of data:
- Filter based on search attributes - ?q=(name='Bill*',birthDate='>2000')
- Show only specific columns - ?v=@(name,birthDate)
- Sort results - ?s=(name='A',birthDate='D')
- Paginate results - ?p=100&l=50

This converter works on all content types.

Today, you can only use this feature by manually adding parameters to the
URL.  However, the HTML view could be enhanced to support....
- Automatic sorting when clicking table column headers.
- Paging links
- Column removal links
- Some sort of search box.

So for example, a column header may contain mini buttons for sorting,
hiding, and searching...

birthDate [^][x][?]

It might be controlled via annotations:  @RestResource(dynamicHtml=true),
@RestMethod(dynamicHtml=true)


===== Hyperlinks for viewing other content types =====

Somewhere on the HTML page, show hyperlinks to render the other possible
content types.  It would highlight the capabilities of the framework if all
the possible media types were only a click away.

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