Abraham Panicker's Weblog
Abraham Panicker's Weblog
Archives
« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today
Click me to subscribe
Search

Links
 

Today's Page Hits: 48

Locations of visitors to this page
Wednesday Nov 07, 2007
Studio Creator .. Loading properties file into dropDown list

One may find it little difficult to load a properties file values into the dropdown list component of Sun Studio Creator 2 update 1. Here I have outlined the steps I have used to create it. 

 1. Check if the Component Library Manager contains the Property Resource Provider Library. This library provides components in Creator for reading Properties file. This library is very useful for localization. Here is an article on how it can be done. If you do not have the library in Creator, you can download it from here and import it into your Creator.

 

 

2. Make sure that dropdown list have been added to the web application page. The dropdown component will be known by its default name dropDown1 in the application code.

3. Make sure that a properties file exist with all key value pairs required for the lookup.

 4. Right click on DropDown List and select 'Bind to data'. Under 'Data Provider to Bind to Dropdown1', make sure to select 'PropertyResourceProvider1'. 'Under Tab 'Bind to Data Provider',  make sure a single valid key and single value field are selected from the left panes and right panes. Under 'Bind to Object' make sure PropertyResourceProvider1 is selected. Click Close.

5. Right Click on DropDown List and select 'Property Bindings', select 'PropertyResourceProvider1' as the Binding Target. Click Close.

6. Add the following code to dropdown list Page1 java source. The code will only work if the source and target setting for the project are changed from Java 1.4  to Java 1.5. This is due to the use of Generics ( found in Java 1.5). One will have to manually edit the project.properties under nbproject directory of this project and change java.source and java.target to a value of 1.5. Rebuilding project with clean option will remove this file. Reediting will be required. One will also have to add option '-source 1.5' to Project properties > Compiling > Additional compiler options. You will not be able to see 'Design Page' after making this change. Your project should however work from this point onwards when deployed.

 Use the prerender method for loading the properties values


 public void prerender() {
       FieldKey [] fldkys = getPropertyResourceProvider1().getFieldKeys();
       ArrayList<Option> options = new ArrayList();
       for (int i = 0; i<fldkys.length; i++) {
            String str1 = getPropertyResourceProvider1().getValue(fldkys[i]).toString();
            System.out.println(" Field Key String "+str1);
            options.add(new Option(fldkys[i].getDisplayName(), str1));
       }
       if(options.size() > 0){
            Option[] optionsArray = new Option[options.size()];
            optionsArray = options.toArray(optionsArray);
            dropDown1.setItems(optionsArray);
        }
    }


Posted at 06:55AM Nov 07, 2007 by apanicker in Java  | 

Friday Jan 12, 2007
My struggle with onload event handler in portlets..

Hi,

Today I had a hard time getting a mashup portlet to work with Google MAPs API. The first issue was that the body tag with onload event handler would not work inside a portlet when using IE 6.0 browser. It worked fine for the Firefox 2.0 browser. For example if you were to stick in a code like the following inside the view.jsp, the onload event would not be called and the load function will not be activated.

It is because, the IE browser rejects a second body tag appearing inside the portlet, when parsing the portal desktop page. The portal desktop page made up of multiple portlets will have its own portlets container 'body' tag. It took me sometime to figure this out.

After fixing that , I ran into another problem where the IE browser would throw an "Operation aborted" error message. A timeout has to be added to the function call, so that function call was made after a set time period. This ensured that the portlet page was parsed before bringing in map content from Google. Following reference helped - http://mapki.com/wiki/FAQs#Browser_Problems. Again this wasn't a problem with the Firefox browser.

setTimeout('load()',500);

Posted at 03:15PM Jan 12, 2007 by apanicker in Java  |  Comments[0]