Embed
Email

xbrl jsf

Document Sample

Categories
Tags
Stats
views:
1
posted:
11/4/2011
language:
English
pages:
8
XBRL Demo: Java Server Faces Application

Valid on the flavors: Platform and above



Summary

This demo is intended to facilitate consumption of a custom DFS service with an application

developed using Java Server Faces.

The application is available at http://corpc:6080/XBRLSubmissions; you could use

“TCM\XBRL\XBRL Submissions - Consumer of a custom DFS webservice” IE bookmark.









Project

The NetBeans project is located under

\\corpc\d$\Demos\XBRL\XBRLSubmissions\XBRLSubmissions



Installation

\\corpc\d$\Demos\XBRL\XBRLSubmissions\XBRLSubmissions\inst\XBRLSubmissions.xml







This file is to be copied to \\corpc\c$\tomcat\conf\Catalina\localhost to install the application.

Configuring the location of a custom DFS service being consumed

\\corpc\d$\Demos\XBRL\XBRLSubmissions\XBRLSubmissions\src\java\com\emc\demo\xbrl\subm

issions\demo.properties

demo.repository=corporate

demo.login=dmadmin

demo.password=d3m04doc

demo.services=http://corpb:9080/services



Developing a JSF application



Page bean component

\\corpc\d$\Demos\XBRL\XBRLSubmissions\XBRLSubmissions\src\java\com\emc\demo\xbrl\subm

issions\Submissions.java



package com.emc.demo.xbrl.submissions;



// imports were cut off



public class Submissions extends AbstractPageBean

{



// auto generated code was cut off



private static Logger logger = Logger.getLogger("com.emc.demo");



public final static String PROPERTIES_FILE_NAME = "demo.properties";

public final static String USER_DIR = "user.dir";



private void readProperties()

{

java.io.InputStream propFile;

try

{

logger.debug(String.format("user.dir=%1$s",

System.getProperty(USER_DIR)));

propFile =

Submissions.class.getResourceAsStream(PROPERTIES_FILE_NAME);

if (propFile != null)

{

java.util.Properties prop = new

java.util.Properties(System.getProperties());

prop.load(propFile);

System.setProperties(prop);

}

}

catch (Exception exc)

{

logger.debug("readProperties(): exception was caught", exc);

}

}



public final static String REPOSITORY_NAME = "demo.repository";

public final static String USER_NAME = "demo.login";

public final static String USER_PASSWORD = "demo.password";

public final static String DEMO_SERVICES = "demo.services";



private String companyName = "%";



public String getCompanyName()

{

return this.companyName;

}



public void setCompanyName(String companyName)

{

this.companyName = companyName;

}



private java.util.Date sinceDate = new java.util.Date();



public java.util.Date getSinceDate()

{

return this.sinceDate;

}



public String getSinceDateAsString()

{

java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-

dd");

return df.format(this.sinceDate);

}



public void setSinceDate(java.util.Date sinceDate)

{

this.sinceDate = sinceDate;

}



public String btnSearch_action()

{

SessionBean1 bean = (SessionBean1) getBean("SessionBean1");

this.readProperties();

bean.setSubmissionInfos(

getSubmissionInfos(

System.getProperty(REPOSITORY_NAME),

System.getProperty(USER_NAME),

System.getProperty(USER_PASSWORD),

System.getProperty(DEMO_SERVICES),

getCompanyName(),

getSinceDateAsString()));

return "success";

}



protected static SubmissionInfo[] getSubmissionInfos(

String repositoryName,

String userName,

String userPassword,

String serviceAddress,

String companyId,

String sinceDate)

{

logger.debug(repositoryName);

logger.debug(userName);

logger.debug(userPassword);

java.util.ArrayList submissionInfos = null;

ContextFactory contextFactory = ContextFactory.getInstance();

IServiceContext context = contextFactory.newContext();

RepositoryIdentity repoId = new RepositoryIdentity();



repoId.setRepositoryName(repositoryName);

repoId.setUserName(userName);

repoId.setPassword(userPassword);



context.addIdentity(repoId);



ServiceFactory serviceFactory = ServiceFactory.getInstance();



ISubmissionsService mySvc;

try

{

mySvc = serviceFactory.getRemoteService(

ISubmissionsService.class,

context,

"submissions",

serviceAddress);



if (isValidCIK(companyId))

{

submissionInfos = (java.util.ArrayList)

mySvc.getLastSubmissionInfosByCIKNumber(companyId,

sinceDate);

}

else

{

submissionInfos = (java.util.ArrayList)

mySvc.getLastSubmissionInfosByCompanyName(companyId,

sinceDate);

}

}

catch (com.emc.documentum.fs.rt.AuthenticationException e)

{

System.out.println("Authentication failed.");

}

catch (ServiceInstantiationException e)

{

e.printStackTrace();

}

catch (ServiceInvocationException e)

{

e.printStackTrace();

}

catch (Throwable t)

{

t.printStackTrace();

}

SubmissionInfo[] si = new SubmissionInfo[submissionInfos.size()];

si = submissionInfos.toArray(si);

return si;

}



private static boolean isValidCIK(String companyId)

{

boolean ok = false;

try

{

ok = Integer.parseInt(companyId) > 0;

}

catch (NumberFormatException exc)

{

// Do nothing

}

return ok;

}

}





The code

 initializes a logger which is used to report any error condition.

 reads properties like repository name, user and its password, as well as DFS service location

from the specified configuration file

 defines properties like companyName and sinceDate which are used to bind from a JSF

component

 defines an auxiliary function isValidCIK() to distinct if a valid CIK number was suipplied or

a company name was provided

 defines a function which requests remote DFS service for submissions

 defines a handler “btnSearch_action” which is invoked when a button on the

page is pressed; this handler does the main activity, it reads properties,

requests a specified DFS service, and stores the response to the session

bean component



Session bean component

\\corpc\d$\Demos\XBRL\XBRLSubmissions\XBRLSubmissions\src\java\com\emc\demo\xbrl\subm

issions \SessionBean1.java



package com.emc.demo.xbrl.submissions;



// imports were cut off



public class SessionBean1 extends AbstractSessionBean

{



// auto generated code was cut off



private SubmissionInfo[] SubmissionInfos;



public SubmissionInfo[] getSubmissionInfos()

{

return SubmissionInfos;

}



public void setSubmissionInfos(SubmissionInfo[] SubmissionInfos)

{

this.SubmissionInfos = SubmissionInfos;

}

}

This code

 defines an array to store the response from the DFS service for the duration of the session or

till the button is pressed again

 defines methods to store and retrieve data



JSF page

\\corpc\d$\Demos\XBRL\XBRLSubmissions\XBRLSubmissions\web\Submissions.jsp





































































































This code

 defines the layout of the JSF components on the web page

 binds components to their corresponding variables like companyName, sinceDate,

btnSearch, and submissionInfos





Thank you



Related docs
Other docs by Stariya Js @ B...
Info pack - Level 1
Views: 0  |  Downloads: 0
f1098746053
Views: 0  |  Downloads: 0
file_116
Views: 3  |  Downloads: 0
Trade
Views: 0  |  Downloads: 0
McKenzie_Law.April
Views: 0  |  Downloads: 0
110208attachmentEndingtheUseofCoalCampaign
Views: 0  |  Downloads: 0
Titration Curve _CBL_ _AP_
Views: 0  |  Downloads: 0
FSSC cover note
Views: 0  |  Downloads: 0
link_130115
Views: 0  |  Downloads: 0
Index_of_Supplementary_Tables_and_Dataset
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!