Hi all,
I have written Small piece of Code for one of the WDK Component:
IIt is helloWorld Component: Onlick o it Fires below JSP and JAVA file:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config version='1.0'>
<scope>
<!-- the following tag defines the id of the component -->
<component id="hello_world_component">
<pages>
<start>/custom/hello_world/DataGrid.jsp</start>
</pages>
<class>com.documentum.webtop.webcomponent.about.DummyComponent</class>
</component>
</scope>
</config>
::::::::::::::::::::::::::::::::::::::::DATAGRID.JSP::::::::::::::::::::::::::::::::::::::::
<%@page contentType="text/html"%>
<%@ page errorPage="/wdk/errorhandler.jsp" %>
<%@ taglib uri="/WEB-INF/tlds/dmform_1_0.tld" prefix="dmf" %>
<%@ taglib uri="/WEB-INF/tlds/dmformext_1_0.tld" prefix="dmfx" %>
<html>
<head>
<dmf:webform />
</head>
<body>
<b>
<font color="orange" size="+1">
List of all users and their privileges.
</font>
</b>
<script>registerClientEventHandler(null, "AlertBhejo", AlertBhejo);</script>
<script type="text/javascript">
function AlertBhejo()
{
alert("Agaya Alert")
}
</script>
<dmf:form>
<dmf:datagrid name="mygrid" paged="true" pagesize="10">
<tr>
<th><b>User Name</b></th>
<th><b>User OS Name</b></th>
<th><b>Group Name</b></th>
<th><b>Def Permits</b></th>
<th><b>Privileges</b></th>
</tr>
<dmf:datagridRow>
<td>
<dmf:text name="quantity" datafield="r_object_id" size="15"/>
<dmf:rangevalidator
name="val_range_quantity"
controltovalidate="quantity"
errormessage="Please enter a quantity from 1-5."
minvalue="1"
maxvalue="5"/>
</td>
<td><dmf:label datafield="object_name"/></td>
</dmf:datagridRow>
</dmf:datagrid>
<td>
</td>
<td><dmf:button name = "Gaddi" label ="Change karo sala" onclick="change_karo"></dmf:button></td>
</dmf:form>
</body>
</html>
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DummyComponent.java
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
package com.documentum.webtop.webcomponent.about;
import com.documentum.web.common.ArgumentList;
import com.documentum.web.formext.component.Component;
import com.documentum.web.formext.session.SessionManagerHttpBinding;
import com.documentum.web.form.Control;
import com.documentum.web.form.control.Label;
import com.documentum.web.form.control.databound.Datagrid;
import com.documentum.fc.client.DfAuthenticationException;
import com.documentum.fc.client.DfIdentityException;
import com.documentum.fc.client.DfPrincipalException;
import com.documentum.fc.client.DfServiceException;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.common.DfException;
public class DummyComponent extends Component
{
Datagrid datagrid = (Datagrid) getControl("mygrid",Datagrid.class);
public void onInit(ArgumentList arg)
{
super.onInit(arg);
}
public void onRender()
{
super.onRender();
Label staticText = (Label) getControl("STATIC_TEXT", Label.class);
staticText.setLabel("My WDK Static Text Value");
Label currentUser = (Label) getControl("CURRENT_DOCBASE", Label.class);
currentUser.setLabel(getCurrentDocbaseName());
try{
datagrid = (Datagrid) getControl("mygrid",Datagrid.class);
}catch(Exception ex){
System.out.println("Creating a new Datagrid Control");
if(datagrid == null)
datagrid = (Datagrid)createControl("mygrid",Datagrid.class);
}
datagrid.getDataProvider().setDfSession(getDocbaseSession());
try {
datagrid.getDataProvider().setQuery("select object_name,r_object_id "+
" from dm_document where "+
"owner_name = "+"'"+getDocbaseSession().getLoginUserName()+"'");
} catch (DfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
datagrid.getDataProvider().refresh();
}
public void change_karo( Control control, ArgumentList argument)
{
setClientEvent("AlertBhejo", null);
}
private IDfSession getDocbaseSession() {
IDfSessionManager sessionManager = null;
SessionManagerHttpBinding httpBinding = null;
IDfSession dfSession = null;
try {
sessionManager = SessionManagerHttpBinding.getSessionManager();
String docbase = SessionManagerHttpBinding.getCurrentDocbase();
dfSession = sessionManager.getSession(docbase);
}catch(DfIdentityException dfe){
System.out.println("Error while obtaining .." + dfe.getMessage());
}catch(DfAuthenticationException ae){
System.out.println("Authentication except .." + ae.getMessage());
}catch(DfPrincipalException pe){
System.out.println("Principal exception " + pe.getMessage());
}catch(DfServiceException se){
System.out.println("Service exception " + se.getMessage());
}return (dfSession);
}
private String getCurrentDocbaseName()
{
String docbaseName = null;
IDfSession dfSession = getDfSession();
try
{
docbaseName = dfSession.getDocbaseName();
}
catch (DfException e)
{
e.printStackTrace();
}
return docbaseName;
}
}
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
What I wanted to DO is to display results of
select object_name,r_object_id "+
" from dm_document where "+
"owner_name = "+"'"+getDocbaseSession().getLoginUserName()
in DATA GRID and once displayed There is Button is JSP called GADDI onlCLick of this Button I want to navigate to Server Side JAVA class and from there a Clinet side even I want To call Which is a simple Alert, But I am Not able to Do that :::::::::
Actually my final Work is, watever is Displayed in DATAGRID I want to EDIt it in CLinet Side JSP, and then Update the Records fetched using THe JAVA CLass......
Any Help How to implement that