Author: bdaw
Date: 2007-07-30 09:17:03 -0400 (Mon, 30 Jul 2007)
New Revision: 7843
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp
Log:
JBPORTAL-1376 - enable to choose google widget by providing URL explicitly
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-07-30
12:59:36 UTC (rev 7842)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-07-30
13:17:03 UTC (rev 7843)
@@ -100,6 +100,12 @@
params.put("query", new String[]{queryParam});
}
+ String pickMethod = req.getParameter("gg_pick_method");
+ if (pickMethod != null)
+ {
+ params.put("gg_pick_method", new String[]{pickMethod});
+ }
+
//
resp.setRenderParameters(params);
}
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp 2007-07-30
12:59:36 UTC (rev 7842)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp 2007-07-30
13:17:03 UTC (rev 7843)
@@ -18,7 +18,7 @@
<div>
<%
- // Get useful request attributes
+ // Get useful request attributes
GGProvider provider = (GGProvider)request.getAttribute("provider");
// Get the selected widget if any
@@ -46,156 +46,217 @@
// Compute query
GGQuery query = new GGQuery(0, catTerm, queryTerm);
Collection widgets = provider.search(query);
+
+ String ggPickMethod = request.getParameter("gg_pick_method");
+ boolean uriPickMethod = false;
+ if (ggPickMethod != null && ggPickMethod.equals("uri"))
+ {
+ uriPickMethod = true;
+ }
+ else
+ {
+ }
%>
+<div id="<p:namespace/>selection">
+ <input type="RADIO" name="gg_pick_method"
value="directory" <%= !uriPickMethod ? "CHECKED" : ""
%>
onclick="document.getElementById('<p:namespace/>directory_search_div').style.display
= 'block';
document.getElementById('<p:namespace/>gadget_url_div').style.display =
'none'; "> Gadget Directory
+ <input type="RADIO" name="gg_pick_method" value="uri"
<%= uriPickMethod ? "CHECKED" : "" %>
onclick="document.getElementById('<p:namespace/>directory_search_div').style.display
= 'none';
document.getElementById('<p:namespace/>gadget_url_div').style.display =
'block'; "> Gadget URI
+ <br>
+ <hr>
+</div>
+<div id="<p:namespace/>gadget_url_div" style="display: <%=
uriPickMethod ? "block" : "none" %>;">
+ <%
+ PortletURL contentURL = renderResponse.createActionURL();
+
contentURL.setParameter("content.action.select","content.action.select");
+ contentURL.setParameter("gg_pick_method", "uri");
+ %>
+ <form action="<%= contentURL %>" method="post">
-<form action="<p:renderURL></p:renderURL>"
method="post">
- <input type="text" name="query"
class="portlet-form-field"/>
- <select name="cat" class="portlet-form-field">
- <option value=""> </option>
- <%
- for (Iterator i = provider.getCategories().iterator(); i.hasNext();)
- {
- GGWidgetCategoryInfo cat = (GGWidgetCategoryInfo)i.next();
- boolean selected = cat.getName().equals(catTerm);
+ <%
+ if (uri != null && selWidget == null)
+ {
+
%>
- <option value="<%= cat.getName() %>" <%= selected ?
"selected=\"selected\"" : "" %>><%=
cat.getDisplayName() %></option>
+ <p style="color: red;">
+ <%
+ out.println("Failed to obtain widget with URI: " + uri);
+ %>
+ </p>
<%
- }
- %>
- </select>
- <input type="submit" value="Search Gadgets"
class="portlet-form-button"/>
-</form>
+ }
+ else if (selWidget != null)
+ {
+ %>
+ <p style="color: blue;">
+ Selected Widget: <%=
selWidget.getDirectoryTitle().getDefaultString().length() > 0 ?
selWidget.getDirectoryTitle().getDefaultString() : selWidget.getTitle().getDefaultString()
%>
+ </p>
+ <%
+ }
+ %>
-<p>
-<table style="width:100%;border:1px solid" cellspacing="0"
cellpadding="0">
+ <input type="text" name="content.uri" value="<%= uri
!= null ? uri : "" %>" class="portlet-form-field"/>
+ <input type="submit" value="Select Gadget"
class="portlet-form-button"/>
+ </form>
+</div>
+
+<div id="<p:namespace/>directory_search_div" style="display:
<%= !uriPickMethod ? "block" : "none" %>;">
+
+ <form action="<p:renderURL></p:renderURL>"
method="post">
+ <input type="text" name="query"
class="portlet-form-field"/>
+ <select name="cat" class="portlet-form-field">
+ <option value=""> </option>
+ <%
+ for (Iterator i = provider.getCategories().iterator(); i.hasNext();)
+ {
+ GGWidgetCategoryInfo cat = (GGWidgetCategoryInfo)i.next();
+ boolean selected = cat.getName().equals(catTerm);
+ %>
+ <option value="<%= cat.getName() %>" <%= selected ?
"selected=\"selected\"" : "" %>><%=
cat.getDisplayName() %></option>
+ <%
+ }
+ %>
+ </select>
+ <input type="submit" value="Search Gadgets"
class="portlet-form-button"/>
+ </form>
+
+ <p>
+ <table style="width:100%;border:1px solid" cellspacing="0"
cellpadding="0">
+ <%
+ for (IteratorStatus i = new IteratorStatus(widgets.iterator());
i.hasNext();)
+ {
+ GGWidget widget = (GGWidget)i.next();
+ boolean selected = selWidget != null &&
selWidget.getId().equals(widget.getId());
+ PortletURL selectURL = renderResponse.createActionURL();
+
+ // Set parameters for selection
+ selectURL.setParameter("content.action.select",
"content.action.select");
+ selectURL.setParameter("content.uri", widget.getId());
+
+ // Set default parametrization state
+ for (Iterator j =
widget.getInfo().getPreferences().getPreferences().iterator(); j.hasNext();)
+ {
+ GGPreferenceInfo prefInfo = (GGPreferenceInfo)j.next();
+ String paramName = "content.param." + prefInfo.getName();
+ String defaultValue = prefInfo.getDefaultValue() != null ?
prefInfo.getDefaultValue() : "";
+ selectURL.setParameter(paramName, defaultValue);
+ }
+
+ // Propagage search nav state
+ selectURL.setParameter("cat", catTerm);
+ selectURL.setParameter("query", queryTerm);
+
+ //
+ String rowClass = selected ? "portlet-section-selected" :
(i.getIndex() % 2 == 0 ? "portlet-section-body" :
"portlet-section-alternate");
+ %>
+ <tr class="<%= rowClass %>">
+ <td><a href="<%= selectURL %>"><%=
widget.getDirectoryTitle().getDefaultString().length() > 0 ?
widget.getDirectoryTitle().getDefaultString() : widget.getTitle().getDefaultString()
%></a></td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+ </p>
+
+</div>
+<div>
<%
- for (IteratorStatus i = new IteratorStatus(widgets.iterator()); i.hasNext();)
+ if (selWidget != null &&
!selWidget.getInfo().getPreferences().getPreferences().isEmpty())
{
- GGWidget widget = (GGWidget)i.next();
- boolean selected = selWidget != null &&
selWidget.getId().equals(widget.getId());
PortletURL selectURL = renderResponse.createActionURL();
// Set parameters for selection
selectURL.setParameter("content.action.select",
"content.action.select");
- selectURL.setParameter("content.uri", widget.getId());
+ selectURL.setParameter("content.uri", selWidget.getId());
- // Set default parametrization state
- for (Iterator j = widget.getInfo().getPreferences().getPreferences().iterator();
j.hasNext();)
- {
- GGPreferenceInfo prefInfo = (GGPreferenceInfo)j.next();
- String paramName = "content.param." + prefInfo.getName();
- String defaultValue = prefInfo.getDefaultValue() != null ?
prefInfo.getDefaultValue() : "";
- selectURL.setParameter(paramName, defaultValue);
- }
-
// Propagage search nav state
selectURL.setParameter("cat", catTerm);
selectURL.setParameter("query", queryTerm);
- //
- String rowClass = selected ? "portlet-section-selected" :
(i.getIndex() % 2 == 0 ? "portlet-section-body" :
"portlet-section-alternate");
+ //propagate visable div
+ if (uriPickMethod)
+ {
+ selectURL.setParameter("gg_pick_method", "uri");
+ }
%>
- <tr class="<%= rowClass %>">
- <td><a href="<%= selectURL %>"><%=
widget.getTitle().getDefaultString() %></a></td>
- </tr>
- <%
- }
- %>
-</table>
-</p>
-
-<%
- if (selWidget != null &&
!selWidget.getInfo().getPreferences().getPreferences().isEmpty())
- {
- PortletURL selectURL = renderResponse.createActionURL();
-
- // Set parameters for selection
- selectURL.setParameter("content.action.select",
"content.action.select");
- selectURL.setParameter("content.uri", selWidget.getId());
-
- // Propagage search nav state
- selectURL.setParameter("cat", catTerm);
- selectURL.setParameter("query", queryTerm);
-%>
-<p>
- <form action="<%= selectURL %>" method="post">
- <%
- for (Iterator i =
selWidget.getInfo().getPreferences().getPreferences().iterator(); i.hasNext();)
- {
- GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
- if (prefInfo.getType().getOrdinal() == DataType.HIDDEN)
+ <p>
+ <form action="<%= selectURL %>" method="post">
+ <%
+ for (Iterator i =
selWidget.getInfo().getPreferences().getPreferences().iterator(); i.hasNext();)
{
+ GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
+ if (prefInfo.getType().getOrdinal() == DataType.HIDDEN)
+ {
- %>
- <input type="hidden" name="content.param.<%=
prefInfo.getName() %>" value="<%= prefInfo.getDefaultValue() != null ?
prefInfo.getDefaultValue() : "" %>"/>
- <%
+ %>
+ <input type="hidden" name="content.param.<%=
prefInfo.getName() %>" value="<%= prefInfo.getDefaultValue() != null ?
prefInfo.getDefaultValue() : "" %>"/>
+ <%
+ }
}
- }
- %>
- <table>
- <tbody>
- <%
- for (Iterator i =
selWidget.getInfo().getPreferences().getPreferences().iterator(); i.hasNext();)
- {
- GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
+ %>
+ <table>
+ <tbody>
+ <%
+ for (Iterator i =
selWidget.getInfo().getPreferences().getPreferences().iterator(); i.hasNext();)
+ {
+ GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
- // Get param value from nav state otherwise we use the default value
- String prefValue = request.getParameter("content.param." +
prefInfo.getName());
- if (prefValue == null)
- {
- prefInfo.getDefaultValue();
- }
- if (prefValue == null)
- {
- prefValue = "";
- }
- %>
- <tr>
- <td><%= prefInfo.getDisplayName() != null ?
prefInfo.getDisplayName() : prefInfo.getName() %>:</td>
- <%
- switch (prefInfo.getType().getOrdinal())
- {
- case DataType.HIDDEN:
- break;
- case DataType.ENUM:
- %>
- <td><select name="content.param.<%= prefInfo.getName()
%>" class="portlet-form-field">
- <%
- EnumType e = (EnumType)prefInfo.getType();
- for (int j = 0;j < e.getSize();j++)
- {
- EnumType.Value value = e.getValue(j);
- boolean selected = value.getValue().equals(prefValue);
+ // Get param value from nav state otherwise we use the default
value
+ String prefValue = request.getParameter("content.param." +
prefInfo.getName());
+ if (prefValue == null)
+ {
+ prefInfo.getDefaultValue();
+ }
+ if (prefValue == null)
+ {
+ prefValue = "";
+ }
+ %>
+ <tr>
+ <td><%= prefInfo.getDisplayName() != null ?
prefInfo.getDisplayName() : prefInfo.getName() %>:</td>
+ <%
+ switch (prefInfo.getType().getOrdinal())
+ {
+ case DataType.HIDDEN:
+ break;
+ case DataType.ENUM:
%>
- <option <%= selected ?
"selected=\"selected\"" : "" %> value="<%=
value.getValue() %>"><%= value.getDisplayValue() != null ?
value.getDisplayValue() : value.getValue() %></option>
+ <td><select name="content.param.<%= prefInfo.getName()
%>" class="portlet-form-field">
+ <%
+ EnumType e = (EnumType)prefInfo.getType();
+ for (int j = 0;j < e.getSize();j++)
+ {
+ EnumType.Value value = e.getValue(j);
+ boolean selected = value.getValue().equals(prefValue);
+ %>
+ <option <%= selected ?
"selected=\"selected\"" : "" %> value="<%=
value.getValue() %>"><%= value.getDisplayValue() != null ?
value.getDisplayValue() : value.getValue() %></option>
+ <%
+ }
+ %>
+ </select></td>
<%
- }
- %>
- </select></td>
- <%
- break;
- default:
- %>
- <td><input type="text" name="content.param.<%=
prefInfo.getName() %>" class="portlet-form-field" value="<%=
prefValue %>"/></td>
- <%
- break;
- }
- %>
- </tr>
- <%
- }
- %>
- <tr>
- <td colspan="2"><input type="submit"
value="Update" class="portlet-form-button"/></td>
- </tr>
- </tbody>
- </table>
- </form>
-</p>
-<%
- }
-%>
-
+ break;
+ default:
+ %>
+ <td><input type="text"
name="content.param.<%= prefInfo.getName() %>"
class="portlet-form-field" value="<%= prefValue
%>"/></td>
+ <%
+ break;
+ }
+ %>
+ </tr>
+ <%
+ }
+ %>
+ <tr>
+ <td colspan="2"><input type="submit"
value="Update" class="portlet-form-button"/></td>
+ </tr>
+ </tbody>
+ </table>
+ </form>
+ </p>
+ <%
+ }
+ %>
</div>
+
+</div>
\ No newline at end of file
Show replies by date