06-24-2010 08:45 AM
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<%@ page import="com.xxxx.alfresco.km.webscripts.WebScriptInvoker"%>
<%@ page import="com.xxxx.alfresco.km.webscripts.WebScriptCall"%>
<%@ page import="java.lang.Integer"%>
<f:verbatim>
<FORM id="1" NAME="myform" ACTION="/jsp/extension/dashlets/kmContributions.jsp" METHOD="POST">
<p>
Number of KM Contributors :
<select id="2" name="number">
<option value="Select">Select</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
</select>
<p>
Location for Search :
<select id="3" name="location">
<option value="Select">Select</option>
<option value="all">All</option>
<option value="xx">xx</option>
<option value="xx2">xx2</option>
</select>
<p>
<INPUT id="4" TYPE="submit" NAME="Search" Value="Search" ">
</FORM>
</f:verbatim>
<%! String number = null; %>
<%! String location = null; %>
<%! String link = null; %>
<%
number = (String)request.getParameter("number");
System.out.println("Top KM Contributors in kmContributions.jsp : "+ number);
location = (String)request.getParameter("location");
System.out.println("Location in kmContributions.jsp "+location);
if(number == null || location == null || number.equalsIgnoreCase("Select") || location.equalsIgnoreCase("Select")){
//Do Nothing
System.out.println("Invalid Value");
}else{
// Call Webscript
System.out.println("valid Value");
link = "/wcs/com/xxxx/km/gettopcontributors?number="+number+"&location="+location;
System.out.println("Web Script URL Value : "+link);
%>
<r:webScript scriptUrl="<%=link%>" />
<%}
%>
res.setContentType("text/html ");
finalOutput +="<f:verbatim>";
finalOutput += "<b>Top "+ num +" KM Contributors in xxxx KM Space for " +location+" location(s) are :</b> <br><br>";
finalOutput += "<html>"+
"<body>"+
"<table border=1>"+
"<tr>"+
"<th>"+
"User Id"+
"</th>"+
"<th>"+
"Total Content "+
"</th>"+
"</tr>";
for(int k = 0; k < cnt ; k++){
finalOutput += "<tr><td align=left>";
finalOutput += finalKeyList.get(k).toString();
finalOutput +="</td><td align=left>";
finalOutput += finalValueList.get(k).toString();
finalOutput += "</td></tr>";
}
finalOutput += "</table></body></html>";
finalOutput +="</f:verbatim>";
logger.debug("finalOutput : "+finalOutput);
res.getWriter().write(finalOutput);
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.faces.FacesException: java.lang.IllegalStateException: Client-id : _idJsp19 is duplicated in the faces tree. Component : dashboard:dash-body:dashlet-3-view:_idJsp19, path: {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /jsp/dashboards/container.jsp][Class: javax.faces.component.html.HtmlForm,Id: dashboard][Class: javax.faces.component.UINamingContainer,Id: dash-body][Class: javax.faces.component.html.HtmlPanelGrid,Id: _idJsp12][Class: org.alfresco.web.ui.common.component.UIPanel,Id: dashlet-3][Class: javax.faces.component.UINamingContainer,Id: dashlet-3-view][Class: org.alfresco.web.ui.common.component.data.UIRichList,Id: pooled-tasks-list][Class: org.alfresco.web.ui.common.component.data.UIColumn,Id: col1][Class: org.alfresco.web.ui.common.component.UIActionLink,Id: col1-act2][Class: javax.faces.component.UIParameter,Id: _idJsp19]}
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:425)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
sun.reflect.GeneratedMethodAccessor498.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy210.doFilter(Unknown Source)
org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
sun.reflect.GeneratedMethodAccessor498.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy210.doFilter(Unknown Source)
org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
root cause
org.apache.jasper.JasperException: java.lang.IllegalStateException: Client-id : _idJsp19 is duplicated in the faces tree. Component : dashboard:dash-body:dashlet-3-view:_idJsp19, path: {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /jsp/dashboards/container.jsp][Class: javax.faces.component.html.HtmlForm,Id: dashboard][Class: javax.faces.component.UINamingContainer,Id: dash-body][Class: javax.faces.component.html.HtmlPanelGrid,Id: _idJsp12][Class: org.alfresco.web.ui.common.component.UIPanel,Id: dashlet-3][Class: javax.faces.component.UINamingContainer,Id: dashlet-3-view][Class: org.alfresco.web.ui.common.component.data.UIRichList,Id: pooled-tasks-list][Class: org.alfresco.web.ui.common.component.data.UIColumn,Id: col1][Class: org.alfresco.web.ui.common.component.UIActionLink,Id: col1-act2][Class: javax.faces.component.UIParameter,Id: _idJsp19]}
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
sun.reflect.GeneratedMethodAccessor498.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy210.doFilter(Unknown Source)
org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
sun.reflect.GeneratedMethodAccessor498.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy210.doFilter(Unknown Source)
org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
root cause
java.lang.IllegalStateException: Client-id : _idJsp19 is duplicated in the faces tree. Component : dashboard:dash-body:dashlet-3-view:_idJsp19, path: {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /jsp/dashboards/container.jsp][Class: javax.faces.component.html.HtmlForm,Id: dashboard][Class: javax.faces.component.UINamingContainer,Id: dash-body][Class: javax.faces.component.html.HtmlPanelGrid,Id: _idJsp12][Class: org.alfresco.web.ui.common.component.UIPanel,Id: dashlet-3][Class: javax.faces.component.UINamingContainer,Id: dashlet-3-view][Class: org.alfresco.web.ui.common.component.data.UIRichList,Id: pooled-tasks-list][Class: org.alfresco.web.ui.common.component.data.UIColumn,Id: col1][Class: org.alfresco.web.ui.common.component.UIActionLink,Id: col1-act2][Class: javax.faces.component.UIParameter,Id: _idJsp19]}
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:329)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:341)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:341)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:341)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:338)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:341)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:341)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:338)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:338)
org.apache.myfaces.application.jsp.JspStateManagerImpl.checkForDuplicateIds(JspStateManagerImpl.java:341)
org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedView(JspStateManagerImpl.java:286)
org.apache.myfaces.taglib.core.ViewTag.doAfterBody(ViewTag.java:125)
org.apache.jsp.jsp.dashboards.container_jsp._jspService(container_jsp.java:540)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
sun.reflect.GeneratedMethodAccessor498.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy210.doFilter(Unknown Source)
org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
sun.reflect.GeneratedMethodAccessor498.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy210.doFilter(Unknown Source)
org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
06-25-2010 08:14 AM
06-29-2010 03:10 AM
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<%@ page import="com.xxxx.alfresco.km.webscripts.WebScriptInvoker"%>
<%@ page import="com.xxxx.alfresco.km.webscripts.WebScriptCall"%>
<%@ page import="java.lang.Integer"%>
<%@ page import="com.xxxx.alfresco.km.property.KmPropertyReader"%>
<%– JSP to get top KM content contributors in xxxx KM Sapce–%>
<f:verbatim>
<FORM id="form1" NAME="myform" ACTION="/jsp/extension/dashlets/topKmContributorSearch.jsp" METHOD="POST">
Number of KM Contributors :
<select id="number" name="number">
<option id="number1" value="Select">Select</option>
<option id="number2" value="5">5</option>
<option id="number3" value="10">10</option>
<option id="number4" value="15">15</option>
<option id="number5" value="20">20</option>
<option id="number6" value="25">25</option>
</select>
<p>
Contributors' Location for Search :
<select id="location" name="location">
<option id="location1" value="Select">Select</option>
<option id="location2" value="all">All</option>
<option id="location3" value="x">x</option>
<option id="location4" value="xx">xx</option>
<option id="location5" value="xxx">xxx</option>
</select>
<p>
<INPUT id="4" TYPE="submit" NAME="Search" Value="Search Contributors">
</FORM>
</f:verbatim>
<%! String number = null; %>
<%! String location = null; %>
<%! String result = null; %>
<%
number = (String)request.getParameter("number");
System.out.println("Top KM Contributors in kmContributions.jsp : "+ number);
location = (String)request.getParameter("location");
System.out.println("Location in kmContributions.jsp "+location);
if(number == null || location == null || number.equalsIgnoreCase("Select") || location.equalsIgnoreCase("Select")){
//Do Nothing
System.out.println("Invalid Value");
}else{
// Call Webscript
System.out.println("valid Value");
KmPropertyReader kmPropertyReader = new KmPropertyReader();
String adminUserName = kmPropertyReader.getProperty("admin.username");
System.out.println("adminUserName : "+adminUserName);
String adminUserPwd = kmPropertyReader.getProperty("admin.password");
System.out.println("adminUserPwd : "+adminUserPwd);
String webScriptUrl = kmPropertyReader.getProperty("topkmconrtibutors.webscripturl");
//System.out.println("webScriptUrl : "+webScriptUrl);
String fullWebScriptUrl = webScriptUrl+number+"&location="+location;
System.out.println("Web Script URL Value in jsp : "+fullWebScriptUrl);
WebScriptInvoker invoker = new WebScriptInvoker();
result = invoker.doWork(adminUserName, adminUserPwd, "GET", fullWebScriptUrl);
//System.out.println("result in jsp!!: "+result);
request.setAttribute("result",result);
%>
<f:verbatim >
<jsp:forward page="/jsp/extension/dashlets/topKmContributorSearchResults.jsp"/>
</f:verbatim>
<%
number = null;
location = null;
}
%>
package com.xxxx.alfresco.km.webscripts;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.Base64;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.apache.log4j.Logger;
public class WebScriptInvoker {
private static Logger logger = Logger.getLogger(WebScriptInvoker.class);
//private static final String USAGE = "java WebScriptInvoker <username> <password> <HTTP method> <web script URL>";
private static NodeService nodeService;
private static PersonService personService;
private String user;
private String password;
private String scriptUrlString;
private String method;
private String ticket;
private String usrName;
public String doWork(String userName, String password, String method, String webScriptURL) {
logger.debug("Inside doWork !!! : userName "+userName+" password "+password+" method "+method+" scriptURL "+webScriptURL);
//String userPwd = getUserPassword();
//logger.debug("userPwd here !!! : "+userPwd);
//System.out.println("userPwd !!! : "+userPwd);
String result;
setUser(userName);
setPassword(password);
setMethod(method);
setScriptUrl(webScriptURL);
logger.debug("userName !!!"+getUser()+" password "+getPassword()+" method "+getMethod()+" scriptURL "+getScriptUrl());
HttpURLConnection conn = null;
try {
AuthenticationUtils.startSession(getUser(), getPassword());
setTicket(AuthenticationUtils.getTicket());
URL scriptUrl = (new URI(getScriptUrl())).toURL();
logger.debug("Invoking Web Script : " + scriptUrl);
conn = (HttpURLConnection)scriptUrl.openConnection();
conn.setRequestMethod(getMethod());
conn.setRequestProperty("Authorization", "Basic " + Base64.encodeBytes((getTicket()).getBytes()));
//3.0 and later can do HTTP method tunneling
conn.connect();
logger.debug("Response code: " + conn.getResponseCode());
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
StringBuffer buffer = new StringBuffer();
String line;
while ((line = in.readLine()) != null) {
buffer.append(line);
}
logger.debug("Web Script Output in doWork() "+buffer.toString());
result = buffer.toString();
} catch (Exception serviceException) {
logger.error("Exception while invoking web script "+serviceException.getMessage());
throw new RuntimeException("Problem invoking web script", serviceException);
} finally {
// End the session
AuthenticationUtils.endSession();
if (conn != null) conn.disconnect();
}
// logger.debug("12");
return result;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getScriptUrl() {
return scriptUrlString;
}
public void setScriptUrl(String scriptUrl) {
this.scriptUrlString = scriptUrl;
}
public String getTicket() {
return ticket;
}
public void setTicket(String ticket) {
this.ticket = ticket;
}
public static NodeService getNodeService() {
return nodeService;
}
public static void setNodeService(NodeService nodeService) {
WebScriptInvoker.nodeService = nodeService;
}
public static PersonService getPersonService() {
return personService;
}
public static void setPersonService(PersonService personService) {
WebScriptInvoker.personService = personService;
}
}
<f:verbatim >
<jsp:forward page="/jsp/extension/dashlets/topKmContributorSearchResults.jsp"/>
</f:verbatim>
07-04-2010 07:31 PM
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/ajax/yahoo/yahoo/yahoo-min.js"> </script>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/ajax/yahoo/connection/connection-min.js"> </script>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/ajax/common.js"> </script>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/webscript.ajax.js"> </script>
//DIV will be replaced by the static content of webscript
<div id="content_will_replaceme" />
function printResult(response){
var z = document.getElementById("content_will_replaceme");
z.outerHTML=response.responseText;
}
function loadDefaults(){
var z = document.getElementsById("content_will_replaceme");
z.innerHTML="<img src='"+getContextPath()+"/images/icons/ajax_anim.gif'/>";
YAHOO.util.Connect.asyncRequest("GET", getContextPath() + "/wcs/myScript",
{
success: printResult,
failure: printResult
},
null);
}
if (window.addEventListener) { //Mozila
window.addEventListener('load', loadDefaults, false);
} else if (window.attachEvent) { //IE
window.attachEvent('onload', loadDefaults);
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.