JBoss Community Archive (Read Only)

RHQ 4.9

Adding a new GWT Portlet to the Dashboard

Adding a new GWT Portlet to the Dashboard

The steps are not complicated but should be captured to help save others time. The goal of the exercise was to duplicate the UI portlet functionality delivered in the JON 2.4 UI using the new SmartGWT architecture and widgets.

The before and after shots

RHQ 3.0.0 UI(Legacy)

images/author/download/attachments/73139258/3.0.0-Dashboard.jpg

View Mode GWT UI

images/author/download/attachments/73139258/4.0.0-Dashboard-view.jpg

Edit Mode GWT UI

images/author/download/attachments/73139258/4.0.0-Dashboard-edit.png

Some differences with the new UI

The dashboard has changed in a number of different ways. The '3.0.0 legacy' dashboard functionality now exists as the 'Default Dashboard' in the GWT based UI.

Add/Removal/Moving portlets

Moving any of the portlets('Recent Alerts', 'Favorite Resources',etc.) now works by drag-n-drop. To add/replace a portlet to the 'Default Dashboard' you need to click the 'Edit Mode' button.

Messages

You now should be aware of the 'Messages' drop down list for errors/exceptions detected and successfully reported back to the UI. Also with the client side elements being built and run in javascript, error messages can now simply go missing or take a while to pop up. This is a side-effect of XHR and asynchronous responses.

Legacy to GWT Dashboard functionality migration

For the first GWT enabled release of RHQ, the legacy JON 2.4 functionality will be migrated to the 'Default Dashboard' area in the new GWT UI. In future releases of RHQ, the 'Default Dashboard' will be one of many optional and customizable views available to the RHQ user. All functionality outside of the 'Default Dashboard' should be considered experimental until that functionality has been successfully rolled into a release.

Default Dashboard Portlet

Refresh

Config

Help

Server Side

Table Footer

Welcome

N/A

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

N/A

N/A

RHQ News

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

N/A

N/A

Discovery Queue

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

N/A

Recent Alerts

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

Recently Added

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

N/A

Operations

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

N/A

Problem Resources

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

images/author/download/attachments/73139258/done.gif

Saved Charts

DTGT

DTGT

DTGT

DTGT

DTGT

Legend:

  • Done|Ready for review images/author/download/attachments/73139258/done0.gif

  • In Progress images/author/download/attachments/73139258/notDone.gif

  • DTGT deferred to Graphing Task completion.

  • Server Side only: ui and widgets are laid out and complete, but changes not yet translated to server requests.

Source code changes for building and registering the new portlet

See below for instructions for how to retrieve the described here:

  1. Build the portlet

    1. Ex. ProblemsResourcesPortlet.java

  2. Build the Smart GWT DataSource for the portlet.

    1. Ex. ProblemResourcesDataSource

  3. Update <Component>GWTService interface to accommodate new DataSource types if necessary.

    1. Ex. ResourceGWTServiceImpl

  4. Register portlet in DashboardsView.getDefaultDashboard()

    1. See DashboardsView.java

  5. Register portlet in PortletFactory initialization block.

    1. See PortletFactory.java

A Pattern for Disambiguation

From a source code perspective, disambiguation requires some changes in the GWT world. With JSF/Struts the data type and resource name disambiguation generation always happened on the server side. With Smart GWT, the final translation of these data types for UI display happens on the client side. This means that translations, like disambiguation, which require server side apis must necessarily still happen on the server side, but the results of that translation needs to be shared as 'translated' data types via serialization. To get all the translated data on the client side means one of two approaches:

  1. Modify the server side composite/entity types to include the disambiguated data

    1. Pros:

      1. Data would be available off of the existing entities as first class level data which is more intuitive.

    2. Cons:

      1. Performance: Disambiguation has a cost in navigating resource hierarchies. Today we only incur the additional cost where it's needed for UI display.

  2. Modify the <Subsystem>GWTServiceImpl code to expose methods for both the entity and the Disambiguated report for that entity.(Chosen Approach)

    1. Pros:

      1. Works today.

    2. Cons:

      1. Necessarily 2 x the previous number of methods for *GWTService and *GWTServiceImpl where disambiguated data needs to be displayed.

      2. Necessarily need to modify all persisted object classes to have default constructors and to use components that comply with GWT serialization.
        After discussing the details above with Lukas, the decision to go with option 2 seemed best.

I want to see some code:

With git clone of http://git.fedorahosted.org/git?p=rhq/rhq.git;a=summary of master branch:

  1. From git project directory run 'git checkout -b new-portlet 4472eb027f3bc43d08b8e061f4091dacf5c9711d', which will checkout a snapshot of JON code and create a new branch 'new-portlet'

  2. Use your java ide or gitk to evaluate the diffs highlighting changes and final versions for working portlet.

Serialization reminders

GWT serialization is not as full featured as Java Serialization even though GWT reuses the java.io.Serializable interface to mark object for serialization. See here for more details.

Basically to avoid some nasty serialization problems with confusing or no error messages, you should make sure the java types being sent over the wire from browser client to RHQ server do the following:

  • Type(s) implements java.io.Serializable.

  • Type(s) have no args constructor.

  • Avoid usage of "Collections.unmodifiableList(java.util.List)", or any other objects/methods that you can't verify/control the serializable aspects(defined in previous two points) for.

Debug errors to watch out for:

Serialized type doesn't meet GWT serialization requirements
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.Collections$UnmodifiableRandomAccessList'
was not included in the set of types which can be serialized by this SerializationPolicy or
its Class object could not be loaded. For security purposes, this type will not be
serialized.: instance = [Resource[id=10003, name='Tomcat (8088)',
type=ResourceType[name='Tomcat Server', plugin='null']],
Resource[id=10001, name='Vital-AGENT', type=ResourceType[name='Linux',
plugin='null']]]
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:610)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write

Unfinished tasks

  1. Revisit portlet functionality with eye for global perms details. In general we should not be showing data that their not authorzed to see(joseph: irc 9/29/10)

    1. Autodiscovery portlet depends on manage inventory perms. If there were no agents at all in the system, we'd show that "Please install and start an agent to get started" message(mazz irc: 9/29/10)

    2. Check other functionality that dissappeared/ operated differently on dashboard with non-rhqadmin privileges.

  2. Icon missing from 'Recent Alerts' -> Configuration -> Assigned Alert Resources.

  3. Auto refresh of portlets(this is pending removal of Quartz apis from SLSB/apis/etc.)

  4. Disambiguation has not been correctly applied to all portlet tables. Likely folded into existing task for converting all Disambiguated resources.

  5. Portlet widgets do not have the updated UI naming to enable selenium hooks.

  6. Rss enable for all portlets. i)new Portlet badge ii) new method for portlets to specify rss urls.

  7. Refactor Portlet work into more generic and better documented mechanism for adding new portlets(add code snippets/simplify).

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 08:20:17 UTC, last content change 2013-09-18 19:40:41 UTC.