Monday, February 20, 2012

Launch MS-Word or PDF using Websphere Portlet Factory.

In order to launch MS-Word or PDF using WebSphere Portlet Factory use the below steps.

Step 1: Use Content Launch Action buider to coordinate the retrieval and browser based handling of application content.



You can render the document on click of image button, button or link. So select the option depending on the requirement. Content Type can either be selected either by file chooser or through a method based on condition.

Content can be retrieved through LJO.





Step 2: Method to retrieve blob object from database.



Above code will fetch the file from database and launch it using Content Launch Action builder.

Store word document into Database using WebSphere Portlet Factory.

This post provides you steps of uploading word or pdf document in database using WebSphere portlet factory.

Step 1: First we need to have a browse a button on the page for browsing the document. Portlet Factory provides a File Upload builder to help our cause. Add File Upload builder into your model. Refer screenshot below.



Select the page and tag depending on your html.
Select Process Upload Errors as it will be required for handling all errors and exception cased while uploading the document.

Step 2 : Now the target is to upload the document on click of submit button into database. We can simply use an LJO to solve our purpose. Lets create a java class and write a method to upload the stream into the database. The file will be stored as blob object. So create a table and have a column to store blob object.




In order to handle errors while uploading the document.



Step 3: Lets include this LJO in our model.




Step 4: Lets map the upload file function to click of submit button.



Above way you can upload the document or pdf in database. Steps can be altered based on the requirement.