On Sep 25, 9:23 am, Tim White <[EMAIL PROTECTED]> wrote:

>  We have a GWT app that works with Google Maps using the gwt-maps
> 'official' API.
>
>  This app is running in WebLogicPortal.  We have a requirement to run
> several copies of the map app, each as a portlet running on the same
> WLP page.
>
> WLP gives each portlet instance on the page a unique identifier.  The
> trick is how to get that id into the app, so that you can keep the
> portlet instances separated in terms up updating the map, and doing
> the normal GWT stuff.

OK, So I have this working, and I thought I'd share how I did it, in
case someone else has to in the future.

What I did is append to a .js array at the top of each portlet's JSP.
So each time the map portlet is run on a page, it will add it's WLP
portlet ID to the array.

In the EntryPoint method, I loop over all the portlet ID's and check
to see if the GWT <div> for that portlet instance is populated yet.
If not, I populate it.

The key is that you have to append to the same .js array across all
the portlet instances....

Tim

WLP JSP:

<%
      PortletPresentationContext context =
PortletPresentationContext.getPortletPresentationContext(request);
      WindowState windowState = context.getWindowState();
      if (windowState != null) {
            pageContext.setAttribute("portletState",
windowState.getName());
      } else {
            pageContext.setAttribute("portletState", "normal");
      }
      String portletInstanceLabel = context.getInstanceLabel();
      if (portletInstanceLabel != null) {
            pageContext.setAttribute("portletInstanceLabel",
portletInstanceLabel);
      } else {
            pageContext.setAttribute("portletInstanceLabel", "none");
      }
%>
…

<div id="NetworkMapContainer-${portletInstanceLabel}"></div>

…

<script type="text/javascript" language="javascript">
      var portalInfo = new Array();
      portalInfo['state'] = '${portletState}';
      var portletInstanceLabel = '${portletInstanceLabel}';
      if ((typeof(mapInstances) == 'undefined')) {
                  var mapInstances = new Array();
      }
      mapInstances['${portletInstanceLabel}'] = '$
{portletInstanceLabel}';
</script>

EntryPoint Class:

              …
             /* Get JavaScript Array of Map Portlet Instances, and
Iterate Over it */
            Dictionary mapInstancesDictionary =
Dictionary.getDictionary("mapInstances");
            Iterator<String> mapInstancesIterator =
mapInstancesDictionary.keySet().iterator();
            String currentMapInstanceKey = "none";
            String currentMapInstanceLabel = "none";
            while (mapInstancesIterator.hasNext()) {
                  /* Determine the Name of the Current Portlet Target
Node */
                  currentMapInstanceKey = mapInstancesIterator.next();
                  if (!currentMapInstanceKey.equals("remove")) {
                        currentMapInstanceLabel =
mapInstancesDictionary.get(currentMapInstanceKey);
                  }
                  /* If we already added a map to this portlet, exit
*/
                  RootPanel currentRootPanel =
RootPanel.get("NetworkMapContainer-" + currentMapInstanceLabel);
                  if (currentRootPanel.getWidgetCount() > 0) {
                        return;
                  }

                  /* Must create a new MapWidget Object, can't use a
final static one */
                  MapWidget mapWidget = new MapWidget();

…

                  /* Add the main Panel to the Page */
                  currentRootPanel.add(mainPanel);
            }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to