Wednesday, February 26, 2020

jdeveloper 12c Performance Boost

We often see that once you install jdeveloper 12c and start development of your application then IDE is very very slow .Follow below steps to improve Jdeveloper 12c performance

Step 1: Configure JVM settings in jdev.conf

Go To path   $MIDDLEWARE_HOME$/jdeveloper/jdev/bin/jdev.conf  and add below lines at the end of the file and save.

# optimize the JVM for strings / text editing

AddVMOption -XX:+UseStringCache

AddVMOption -XX:+OptimizeStringConcat

AddVMOption -XX:+UseCompressedStrings

# if on a 64-bit system, but using less than 32 GB RAM, this reduces object pointer memory size

AddVMOption -XX:+UseCompressedOops

# use an aggressive garbage collector (constant small collections)

AddVMOption -XX:+AggressiveOpts

# for multi-core machines, use multiple threads to create objects and reduce pause times

AddVMOption -XX:+UseConcMarkSweepGC

AddVMOption -DVFS_ENABLE=true

AddVMOption -Dsun.java2d.ddoffscreen=false

AddVMOption -XX:+UseParNewGC

AddVMOption -XX:+CMSIncrementalMode

AddVMOption -XX:+CMSIncrementalPacing

AddVMOption -XX:CMSIncrementalDutyCycleMin=0

AddVMOption -XX:CMSIncrementalDutyCycle=10



Step 2: Configure java memory settings in ide.conf file

Go To  path  $MIDDLEWARE_HOME$/jdeveloper/ide/bin/ide.conf and search for Xms and Xmx values and change it as below and save.this will significantly improve you jdeveloper speed.


# Set the default memory options for the Java VM which apply to both 32 and 64-bit VM's.

# These values can be overridden in the user .conf file, see the comment at the top of this file.

AddVMOption -Xms2048M

AddVMOption -Xmx4096M


Step3 :Disable Build on save Option

Go To Tools->Preferences->Code Editor->Save Actions






Step 4 :Remove Non required features

Go To Tools->features and i removed below which are not required generally.you can do more if it is not relevant to you.





















Step 6 :Select default editor for jsff and jspx files.

By default jsff and jspx files open in design mode and hence it takes longer time for them to open.so to open it is source code do below

Go To Tools->preferences->File Types->Default editors (Tab)













Restart your Jdeveloper and enjoy the faster jdeveloper :)

Monday, February 24, 2020

Keep Scroll Position in ADF page/jsff


Requirement
usually we have long form in ADF jsff or jspx with many input fields tables etc on same page .Since fields are more we get vertical scroll bar .Now when user fill in all information on the page and scrolls down to click submit.If there are any errors in fields we show error message using below snippet.

 FacesContext ctx = FacesContext.getCurrentInstance();
 FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error .", "Please correct email address and confirm email address");
        ctx.addMessage(null,fm);








Now when we click OK page goes to top and scroll position is not maintained.


Solution :

just use an actionListener on submit button and the attribute partialSubmit="true" on the button or link.
due to this when click on submit  a partial submit will be executed instead of a full page reload.
In this case you would need to programmatically refresh components you want to refresh on click of submit  using   addPartialTarget(bindingofcomponent) in Java or the attribute partialTriggers="idofcomponent" on the components which should update because of that partial submit of submit button

Thursday, February 20, 2020

ADF -Rendering components based on other components selected values


Requirement: usually we come across this simple requirement where we want to display certain component on certain value selected by user on UI

E.g. I have drop down and based on selected value either I want to display inputText field or inputDate field
Usually developer will add the partial target on inputtext and inputdate field and will expect it to work with below code

<af:form id="f1">          
                <af:spacer height="100"></af:spacer>
                <af:selectOneChoice  autoSubmit="true" id="tsk1" label="Select value"
                                    unselectedLabel="--select--" binding="#{CustomBean.ctask}">
                    <af:selectItem label="Show input text" value="test1"></af:selectItem>
                    <af:selectItem label="Show input Date" value="test2"></af:selectItem>
                </af:selectOneChoice>
                <af:spacer height="30"></af:spacer>
                <af:inputText required="#{CustomBean.ctask.value eq 'test1'}"
                              rendered="#{CustomBean.ctask.value eq 'test1'}" partialTriggers="tsk1" id="inp1"
                              label="Input Field 1" binding="#{CustomBean.textBinding}"></af:inputText>
                <af:inputDate required="#{CustomBean.ctask.value eq 'test2'}"
                              rendered="#{CustomBean.ctask.value eq 'test2'}" partialTriggers="tsk1"
                              label="Input Field 2" binding="#{CustomBean.dateBinding}"></af:inputDate>
                <af:spacer height="30"></af:spacer>
                <af:button text="submit"></af:button>          
        </af:form>





But this doesn’t work and my input text component doesn’t show up as we have applied render condition and not visible condition on inputtext and inputdate component .



Reason for this is if you want to render component at a runtime then you need to refresh parent layout component so I added panelGrouplayout and partial trigger on the same and code will look like below


<af:form id="f1">
            <af:panelGroupLayout partialTriggers="tsk1">
                <af:spacer height="100"></af:spacer>
                <af:selectOneChoice  autoSubmit="true" id="tsk1" label="Select value"
                                    unselectedLabel="--select--" binding="#{CustomBean.ctask}">
                    <af:selectItem label="Show input text" value="test1"></af:selectItem>
                    <af:selectItem label="Show input Date" value="test2"></af:selectItem>
                </af:selectOneChoice>
                <af:spacer height="30"></af:spacer>
                <af:inputText required="#{CustomBean.ctask.value eq 'test1'}"
                              rendered="#{CustomBean.ctask.value eq 'test1'}" partialTriggers="tsk1" id="inp1"
                              label="Input Field 1" binding="#{CustomBean.textBinding}"></af:inputText>
                <af:inputDate required="#{CustomBean.ctask.value eq 'test2'}"
                              rendered="#{CustomBean.ctask.value eq 'test2'}" partialTriggers="tsk1"
                              label="Input Field 2" binding="#{CustomBean.dateBinding}"></af:inputDate>
                <af:spacer height="30"></af:spacer>
                <af:button text="submit"></af:button>
            </af:panelGroupLayout>
        </af:form>

And now my input text and input date renders at runtime as below





















This works in 12c but in 11g you will need refresh the panelgrouplayout programmatically in value changeListener of select one choice drodown using below statement

AdfFacesContext.getCurrentInstance().addPartialTarget(valueChangeEvent.getComponent().getParent());

Tuesday, February 18, 2020

Oracle ADF 12c -Wrapping long text of af:link/af:outputtext

Requirement -Wrapping long text of any link so that it fits into small layout in ADF 12c.

Below code snippet for af:link works perfectly

<af:link text="Test for wrapping link with long text to fit into small layout"
                         inlineStyle="word-wrap:break-word;display:inline-block;width:150px;white-space: normal;"></af:link>

Please note that you need to give width according to your requirement and space available in layout.

same works for wrapping  the af:outputtext 

<af:outputText value="Test for wrapping link with long text to fit into small layout"
                         inlineStyle="word-wrap:break-word;display:inline-block;width:150px;white-space: normal;"></af:outputText >

image.png

Monday, February 17, 2020

Change the Jdeveloper JDK version


if you want to change the JDK version used on our local jdeveloper Two things need to be done

  1. Change the jdk version of Jdeveloper for compilation
  2. Change the JDK version of Integrated weblogic servers.

Changing the JDK version of jdeveloper

  1. Go to MIDDLEWAREHOME\jdeveloper\jdev\bin
  2. open jdev.conf in notepad
  3. edit below line to point to new JDK version and save file
SetJavaHome C:\Oracle\Middleware\jdk1.7.0_79

restart jdeveloper and go to help-->about-->version tab to see new jdk version as shown in below screenshot

Changing the JDK version of Integrated Weblogic server


  1. go to default domain folder of local weblogic server .e.g path C:\Users\XXXX\AppData\Roaming\JDeveloper\system11.1.1.9.40.66.73\DefaultDomain\bin
  2. Open setDomainEnv.cmd (Windows)/setDomainEnv.sh file (Linux)(.cmd for Windows)
  3. replace the SUN_JAVA_HOME and JAVA_HOME with new JDK version path as shown below
#set SUN_JAVA_HOME=C:\Oracle\Middleware\jdk160_29
set SUN_JAVA_HOME=C:\Oracle\Middleware\jdk1.7.0_79

if "%JAVA_VENDOR%"=="Oracle" (
set JAVA_HOME=%BEA_JAVA_HOME%
) else (
if "%JAVA_VENDOR%"=="Sun" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
set JAVA_VENDOR=Sun
set JAVA_HOME=C:\Oracle\Middleware\jdk1.7.0_79
)
)

restart local weblogic server .While server is starting the new JDK path will show in logs as below






Identify ADF Skinning css style class


We often have requirement to customize the ADF component style class For example ,customize font color and size of panelbox header.

When we inspect the panelbox header in browser by doing inspect element on component we get classes  as shown in below screenshot which are not useful and not what developer is looking for .




Add below context parameter in web.xml file and set param-value to true

<context-param>
        <description>If this parameter is true, there will be an automatic check of the modification date of your JSPs, and saved state will be discarded when JSP's change. It will also automatically check if your skinning css files have changed without you having to restart the server. This makes development easier, but adds overhead. For this reason this parameter should be set to false when your application is deployed.</description>
        <param-name>org.apache.myfaces.trinidad.DISABLE_CONTENT_COMPRESSION</param-name>
        <param-value>true</param-value>
  </context-param>

Run the application again and see how the actual style class shows up as below.Now you can use these in ADF skinning css file to change the font color ,size etc.













Sunday, February 16, 2020

ADF PanelBox CSS customization


Requirement:Customize ADF panelbox css to have different open and closed panelbox icons and background color,border etc

In adf when we use panelbox with detault css it looks like below

<af:panelBox  text="Panel box Header 1" inlineStyle="width:400px;padding-left:20px;">
    
     <af:outputText value="Panel box content" ></af:outputText>
   </af:panelBox>


Customize the css as below and create customPanelbox style class as below


.customPanelBox af|panelBox::header-start:core:default {
    border-top: 1px solid #BFBFBF;
    border-left: 1px solid #BFBFBF;
    display: none;
    background-image: none !important;
    background-color: #ffffff !important;
    padding-left: 0px !important;
}

.customPanelBox af|panelBox::header-center:core:default {
    border: 1px solid #BFBFBF;
    border-bottom: none !important;
    background-image: none !important;
    background-color: #ffffff !important;
}

.customPanelBox af|panelBox::center:core:default {
    background-image: none;
    border: 1px solid #BFBFBF !important;
    background-color: #ffffff !important;
    padding-left: 0px !important;
    padding-left: 0px !important;
    padding-right: 0px !important;
    border-top: none !important;
    border-bottom: none !important;
    padding-left: 24px !important;;
    padding-bottom: 24px !important;;
    padding-right: 24px !important;;
}

.customPanelBox af|panelBox::footer-start:core:default {
    border-top: 1px solid #BFBFBF;
    border-left: 2px solid White;
    background-color: #ffffff !important;
    background-image: none !important;
    width: 0px !important;
    height: 0px !important;
}

.customPanelBox af|panelBox::footer-center:core:default {
    border-top: 1px solid #BFBFBF;
    background-color: #ffffff !important;
    background-image: none !important;
    width: 0px !important;
    height: 0px !important;
}

.customPanelBox af|panelBox::footer-end:core:default {
    border-top: 1px solid #BFBFBF;
    border-right: 0px solid White;
    background-color: #ffffff !important;
    background-image: none !important;
    width: 0px !important;
    height: 0px !important;
}

.customPanelBox af|panelBox::header-text {
    font-size: 22px !important;
    color: #000000 !important;
    font-weight: 300 !important;
    padding-left: 0px !important;;
}

.customPanelBox af|panelBox::header-end {
    background-image: none !important;;
    display: none;
    background-color: #ffffff !important;
}

.customPanelBox af|panelBox::disclosed-icon-style {
    background-image: url("../images/Darrow.png")!important;
    padding-left: 48px;
    padding-top: 24px;
    padding-bottom: 24px;
    background-repeat: no-repeat !important;
    background-position: center;
    background-color: #ffffff;
    align: right !important;
    background-size: 20px 11px !important;;
    width: 20px !important;
    height: 11px !important;
}

.customPanelBox af|panelBox::undisclosed-icon-style {
    background-image: url("../images/UpArrow.png")!important;
    padding-left: 48px;
    padding-top: 24px;
    padding-bottom: 24px;
    background-repeat: no-repeat !important;
    background-position: center;
    background-color: #ffffff;
    align: right !important;
}

.customPanelBox af|panelBox::header-element {
    font-size: 22px !important;
    color: #000000;
    font-weight: 300 !important;
}
The UI code will look like below
 

The New panel box for which customPanelBox style class is applied will look like below and the panelbox for which we have not applied any style class that will continue to look like default adf panelbox



Saturday, February 15, 2020

ADF Open/Close af:PanelBox with click on panelbox header



In ADF panelbox is closed or open on click of icon in header icon and not on text in panel box header

With Below code snippet you can open/close  panelbox on click of anywhere in header.

<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <af:document title="PanelBoxTester.jsf" id="d1">
    <af:resource type="javascript">
       function togglePanelBox(mouseEvent){
          var panelBox = mouseEvent.getSource();
          panelBox.broadcast(new AdfDisclosureEvent(panelBox, !panelBox.getDisclosed()));
       }
     </af:resource>
        <af:form id="f1">
          <af:panelBox text="PanelBox1" id="pb1">
              <f:facet name="toolbar"/>
                <af:clientListener method="togglePanelBox" type="dblClick"/>
            </af:panelBox>
        </af:form>
    </af:document>

</f:view>