Pages

Tuesday, January 13, 2015

Accessing Context Root Programatically


There are several needs to access context root in various places of your application.

Various ways are,

In Jspx${pageContext.request.contextPath}

In servlet:
    public static String getContextpath(HttpServletRequest request) {
        return request != null ? request.getContextPath() : null;
    }

In bean:
   public static String getContextpath() {
        ExternalContext extContext= FacesContext.getCurrentInstance().getExternalContext();
        String url = extContext.getRequestContextPath();
        return url;
    }

In Javascript:
function getContextPath(){
            return window.location.pathname.substring(0,window.location.pathname.indexOf("/",2));
            }

In CSSbackground: url(../resources/images/header.jpg")

Wednesday, January 7, 2015

Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/Server


Few weeks back, My JdeveloperR2 set up got corrupted.Best way to clean up and install it again.For some reasons i dint clean up my entire stuff.


With Existing Config. I start installing JdeveloperR2.During weblogic server start up.I caught this exception.

Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/Server
Caused by: java.lang.ClassNotFoundException: weblogic.Server
     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 


After few readings, I came to know class path is not mapped properly.Even though I mapped properly, repeatably got this exception.


Later, I Noticed some mapping where not right in setDomainEnv.sh File. Mappings in setDomainEnv.sh referring to my corrupted set up.

Finally, Resolved by this way,


Go to the location: C:\Users\xxxx\AppData\Roaming\JDeveloper\system11.1.2.4.39.64.36.1\DefaultDomain\bin\setDomainEnv.sh

set COMMON_COMPONENTS_HOME=F:\Oracle\Middleware\oracle_common
set WC_ORACLE_HOME=F:\Oracle\Middleware\jdeveloper
set PORTLET_ORACLE_HOME=F:\Oracle\Middleware\jdeveloper
set WC_ORACLE_HOME=F:\Oracle\Middleware\jdeveloper
set WL_HOME=F:\Oracle\Middleware\wlserver_10.3

set SUN_JAVA_HOME=F:\Oracle\Middleware\jdk160_24

Note :Please ensure that these mappings where pointed to correct specified location in your .sh file. 
if they were right, class path is actual problem.

After rectifying this Exception, Then I can run my startWebLogic.sh.

Now Works Fine.

Monday, July 7, 2014

Accessing Resource Bundle

For generic application, resource bundle plays a major role.

All we  need is, just create a file named say as e.g.: 'dummy' extension should be in '.properties'

Step 1: Register your file in faces-config.xml
Application > Resource Bundle Section. 
Define a variable name to use over the application.

 



Step 2: Define your label




Step 3: Access your label from resource bundle.  


Step 4: Finally,


 Download Here

Saturday, June 14, 2014

Switcher in ADF

A requirement lead me to play around the components. while clicking button I need to toggle components. 

Requirement rules:
1.Should not use render/visible property.
2.Toggle should happen page itself. it should not taken it into bean.
I studied about switcher.I got a chance to implement it.

Step 1: Have Switcher in your page. Under switcher have your components. 

Important note: 
             Components should folds of f:facet. Switcher facet Name play key role. it will decide which will show up on the screen. 



Step 2: Finally requirement accomplished.

Clicking First button,



Clicking Second button,



Download here

Enable/Disable the Input Fields/Input Value holders

Here I got requirement like Enable/Disable the bunch of fields. It's hard to bind each and every fields and toggle it. I read some blogs. Accessing appropriate classes we can do that.


Step 1: Here we go, standard code for accessing class with appropriate attributes.



Step 2: While clicking edit button call out the method.
pass the 'AdfFacesContext' Instance , bind the Parent Layout and pass the appropriate Boolean values. 


Step 3: Finally call out the method for update button.


Note : Code will works, First Level Immediate Children as like of structure shown.



Download Here

Debugging in ADF - Part I

Developer & Development Time basically get reduces if you are using Debugger WLS,

Here we go,

1.System.out.println  -  Newbie will use s.o.p each and every statement. so what's going on.
2.Avoid Re-run. - For a Small Change in Java Class(Application Module/EO/VO/Bean). No Need to Run Entire Application.
3.Bug Findings - Easy error findings.

Various Options for Debugging:

Option 1:  By using this statement "-Djbo.debugoutput=console"  in Model Layer. you can see SQL query being sent to server in your console log.



Note : If you are going to use this option means, After pressing OK button. need to restart your server.

Option 2:  Have a break point (by pressing 'F5') in your java code.then start debugger along with your application.




While Performing Selection/Action. By pressing F8(Step by step execution on code)
By pressing F9(Navigate to Next Break point). Blue Color shows Execution Point.




After execution of a row. you can mouse over on the particular class for see the values.
say as e.g.: After execution row class. I can able to see a entire row what i selected in page.



Options 2.1: By using "EL Evaluator" you can debug. With the help of El expression i can able to get the row count.



Options 2.2: By this "Smart Data" you can debug Model and its values (say as e.g.: debug the queries)



Options 2.3: By this "Data" you can debug the Bean and its values.




Options 2.4 : By this "ADF Data" you can debug the Various Scope and its values

Request Scope: Bindings Flows out on this scope.



View Scope: PageDef Flows out on this scope.



Session Scope: Active Data Services Flows on this scope.




Application Scope: Application name and its location flows on this scope.


 

While debugging,
In Browser: Few couple of things can able be noticed


In Application Data: Entire db data can able to see here



I

By this way you see the state of Enity Object and its Data.



In Jspx Page: By this way you see the entire value and expersion of an Page.



Option 3:  Configuring Diagnostic Logging.



Tune into Finest Level.


These are the various kind of Debugging.

Debugging Part 2 & 3(LifeCycle Level) in future posts.

Select Boolean Check Box in ADF

Here I got a requirement like on select boolean check box, while selecting a row corresponding row check box should be selected.


Step 1: As per requirement, I added a Transient Attribute as Boolean and also i make it is as passivated.



Step 2: Then I drag and drop as Table. By default it will input text box. select the Check Box field then use right click select 'Convert To..' option. Another panel box will opens in that choose "Select Boolean Check box". Click OK button. Finally it looks like following image



Step 3: Two things need to do.

First one remove the existing Selection Listener.Then use edit option it will direct you to create a bean and register then bean in adfc-config.xml(automatically).

Second one bind your af:table in bean.



Step 4: With help of ADF Utilities make our work easy. Our af:table work functionality based on 'Collection Model' Class. 'makeCurrent' will identify the user row selection.




Grab the Current Row, based on selection set value as true. 
Make PPR on af:table.

Step 5: Finally requirement accomplished.




Download Here

Thursday, May 15, 2014

Activation and passivation will not happens

In Connection with my previous post Activation and passivation in ADF
 
If you uncheck following flag means
1.Enable Application module pooling
2.passivate state and Include All transient Values.
passivation wont happens.there is no active record to activate. i.e activation/passivation wont happens
then re-run your application.

then result would be.

Step 1: After Un-check flag. re-running the existing application.
enter the data press submit.




Step 2: Log shows that after each request application module & jdbc connection created and closed.

while Observing when creating a record a 
**insert** id =1,parid=1,collid=98312,...

Notice one more thing "delete all" collid=98311
collid is field of an PS_TXN table.delete "PS_TXN" where collid =:1


Finally at this end. no passivation store happens, so while activation no record fetching takes places.


 

Download here.

Note: Before running this application un-check the concern flag. "Activation and passivation will not happens"

Activation and passivation in ADF

Here we go with an sample application how activation/passivation works. I'm having application constructed with help of transient view object in model layer.

Step 1: Enable Application Module Pooling.



By default flag checked. with the help of this flag activation/passivation will happens.


Step 2: Creation of transient view object



Step 3: Checking all transient attribute for performing passivation.



if you do the step2 means all value all those attributes in this transient viewobject will be passivated.

Step 4: All attributes passivate flag is checked. 



Note : if you dont want to passivate all attributes in an viewobject means don't check "Including All Transient Values"

you can able to passivate the transient needed individual attribute.
see the following figure.




That's all now activation/passivation will handle by the framework by default.
It will works upon Application Module Connection pooling parameters.

Step 5: Same Transient View objects instance shared in two jspx pages one as af: form and another one as af:table.

Step 6: for debugging use this -Djbo.debugoutput=console
DC Instantiation happening.




Loading BC4J default properties and as previous blog told that       PS_TXN creation.                                              

 
Additional logs.                                                                                                                                                                    

Step 7: After pressing create insert button.



Along with its log. 



Step 8:  After Submit the data to server.



Along with its log.




Step 8: Go to next View page.



 Finally record passivate gets activated.



Download here