Pages

31 October 2010

Use only the rules of your preference with PMD

There is a defect in JDeveloper’s PMD plug in and “Import rules file” actually does nothing.
Maiko Rocha has an excellent post regarding applying your rules in PMD (and so in the above Rules frame have only your rules) 

Notes:

  1. TROUBLESHOOTING: While creating jar, it might break if compress folder as zip with winrar and then rename it as jar
  2. Regarding PMD plug in: In conf dir there is a file called pmd.rule.properties in there plugin marks as true the rules that user has selected




22 October 2010

Fix Lov that does not return Secondary Attr values when Primary Value is the same

...or Different Secondary attrs cannot be selected for the same primary attr

Scenario

Let's say that we have a VO based on entity that has t least attrs:
  1. AttrPK1 which is  PK
  2. AttrPK2 also a PK
  3. AtrrsDesc is a required description
The 1st attr "AttrK1" we have an LOV that returns all 3 attrs


The following scenarion breaks it:

  •  raise LOV 
  • select a different row that has the same AttrPK1  but differnetAttrPK2  and press ok
  • then LOV does not return the AttrPK2 and Desc based on the different row cos AttrPK1 that the Lov is on did not change and it thinks that there no changes



Solution

In order to fix this we change AttrPK1 Lov 

page
     
                                            popupTitle="Lov title"
                                            value="#{bindings.AttrPK1.inputValue}"
                                            label="#{bindings.AttrPK1.hints.label}"
                                            model="#{bindings.AttrPK1.listOfValuesModel}"
                                            required="#{bindings.AttrPK1.hints.mandatory}"
                                            shortDesc="#{bindings.AttrPK1.hints.tooltip}"
                                            simple="true" autoSubmit="true"
                                            launchPopupListener="#{backing.attrPK1_LaunchListener}">
                       
                      

backing
   public void attrPK1_LaunchListener(LaunchPopupEvent launchPopupEvent) {
        //Always trigger the value change event.
        triggerValueChange(this.getAttrPK1());
    }

    /**
     * Triggers a change in the specified control's value.
     * The change is triggered even if there is not an actual change by the user.
     * Useful in cases where we always want the component to call its value change listener.
     */
    private void triggerValueChange(UIXValue cntrl) {   
        //trigger only when the control already has a value
        if (cntrl.getValue() != null) {
            //put a dummy value just to trigger value change
            cntrl.setValue(" ");
        }
    }

Note: In application module it wotks ok


Special Thanx to: Evgenia Maniati

Run a trial version of an app in VirtualBox beyond trial time

...or Configuring time sync of VirtualBox.

Although not ADF related it worths posting.

Found excellent post by Serafim http://serafeimk.blogspot.com/2010/10/time-sync-virtualbox.html .
Just reposting his tips:

Prerequirements:
Host machine: Linux
Guest in VirtualBox also Linux

Tip:
  • Close vm 
  • Write VBoxManage setextradata [VMname] "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1" in order to desynchronize the host clock with the guest clock
  •  Run vm and the trial program without complaining
  • Restore sync VBoxManage setextradata [VMname] "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "0"
Thanx Serafim

19 October 2010

Clean and disable MDS information from WLS

Clean 
Steps:
  • Remove MDS folder in %USER_DIR%\system11.1.1.3.37.56.60\o.mds.dt\adrs
  • Remove temp folder in %USER_DIR%\system11.1.1.3.37.56.60\DefaultDomain\servers\DefaultServer\tmp
  • Remove deployed applications in %USER_DIR%\system11.1.1.3.37.56.60\o.j2ee\drs
where $USER_DIR is the windows user directory
eg.
$USER_DIR=C:\Documents and Settings\spiros\Application Data\JDeveloper

Disable


 Remove check from "Enable User Customazation" check box.

15 October 2010

Disable an af:menu when all of its children are disabled


If you have a  requirement that a menu which has all of its children (menu items , go menu items , sub menus) disabled then the menu should also be disabled, then instead of writing the same conditions that you had to the children to the menu (boring and error prone) you can just use the following.


1. 
bind the af:menu to the backing bean, that is the binding prop eg. 
binding="#{myBacking.myMenu}"

2. 
set the disable property of the af:menu to a backing bean property e.g. 
disabled="#{myBacking.myMenuDisabled}"
where the the backing bean method is 
public boolean isMyMenuDisabled() {
return isMenuDisabled(this.myMenu);
}

3.
In the backing property method use the following method (you can decide if it should be placed to a generic class eg Backing beans Super class or in a Utils class as a statis method (e.g. like methods in ADFUtils))
/**

* In order to be disabled ALL children (&&) must be disabled
* @param menu
* @return
*/
protected boolean isMenuDisabled(RichMenu menu) {
 boolean isDisabled = true;
 List children = menu.getChildren();
 logger.debug("parse children ");
 Iterator iter = children.iterator();
 while (iter.hasNext()) {
  Object o = iter.next();
  if (o instanceof RichMenu) {
   RichMenu childMenu = (RichMenu)o;
   logger.trace("Found submenu with id: "+childMenu.getId());
   boolean isChildMenuDisabledProperty = childMenu.isDisabled();
   if (isChildMenuDisabledProperty ) {
    isDisabled = isDisabled &&    isChildMenuDisabledProperty;
    logger.trace("submenu with id:"+childMenu.getId()+" returned  (prop based) : " +
    isChildMenuDisabledProperty);
   }
  else {
   boolean isChildMenuIsDisabled = isMenuDisabled(childMenu);
   isDisabled = isDisabled && isChildMenuIsDisabled;
   logger.trace("submenu with id:"+childMenu.getId()+" returned   (parsed) : " + isChildMenuIsDisabled);
  }
 } else if (o instanceof RichCommandMenuItem) {
   RichCommandMenuItem menuItem = (RichCommandMenuItem)o;
   isDisabled = isDisabled && menuItem.isDisabled();
   logger.debug("Found menuItem with id: " + menuItem.getId() + " and disabled condition: " +
   menuItem.isDisabled());
 } else if (o instanceof RichGoMenuItem) {
   RichGoMenuItem goMenuItem = (RichGoMenuItem)o;
   isDisabled = isDisabled && goMenuItem.isDisabled();
   logger.debug("Found gomenuItem with id: " + goMenuItem.getId() + " and disabled condition: " +
  goMenuItem.isDisabled());
 } else if (o instanceof RichSeparator) {
  logger.debug("separator found. ingnoring...");
 } else {
   logger.info("Not Supported. Menu Item can only have: menu,   menuItem, goMenuItem ot separator.");
   }
  }
 return isDisabled;
}
It supports that the menu can have as its children:
° Sub menus
° menuItems
° goMenuItems

You can check other props also like visible and rendered prop.

PS: this was a repost from my other blog

TROUBLESHOOTING: Reset the values of the UI components in order to get refreshed from model

Problem 
We have a af:popup that its value should be cleared its time it was raised.
The fields of the popup were based on transient attributes of SQL Based VO.
For that reason each time the popup was raise the VO was executed (to take its initial values)
The problem was that in hte popup the values were not cleared.

Solution
 I came across this excellent post
http://adfbits.blogspot.com/2008/11/sticky-popup-values.html
 Using the following method after executing the SQL based VO (below is the function a bit modifying):
public void resetStaleValues(UIComponent rootComponent){
  Iterator iter = rootComponent.getFacetsAndChildren();
  while (iter.hasNext()) {
   UIComponent component = iter.next();
   if (component instanceof UIXEditableValue) {
     UIXEditableValue uiField = (UIXEditableValue)component;
   uiField.resetValue();
   //a little mod here: Also refesh the component
   RequestContext.getCurrentInstance().addPartialTarget(uiField);

  }
   resetStaleValues(component);
}

You can also enrich  your code by including functinality to set value null with methods like:

12 October 2010

Increasing the memory of embedded weblogic


Why
Be default embedded weblogic (this is the weblogic that comes with the JDeveloper installation) uses 512MB only, which for a really big application is enough for 2-3 deployments without restarting server (this are deployments that are performed by JDeveloper in the background each time we run our Fusion application). Moreover, its a waste to have so much memory in nowadays workastations without using it. So, this will give us the ability to have more redeployments without server restart, and do test something faster.

How
The only thing you need to do is to the add the following line in setDomainEnv.cmd file right after the comments in the beginning:

set USER_MEM_ARGS=-Xms64m -Xmx1024m -XX:MaxPermSize=512m

in the above example I am setting it to have 1024 and 512 perm.

setDomainEnv.cmd is located in a different folder that the previous release of JDev:
C:\Documents and Settings\user\
Application Data\JDeveloper\system11.1.1.1.33.54.07\DefaultDomain\bin 
(in this example is windows user app data folder. )

Note1:
Actually the system dir is displayed in JDeveloper's console each time the embedded weblogic starts.


Note2:
Setting mem config is changed in the new WLS 10.3.1. and in the embedded WLS of JDevelper 11.1.1.1.1.0 (actually this is the same thing). In the previous ver it was setted like this.

Adding a lib / jar dependency to my project

Create new File System Connetion to the directory tha contains the external libs/jars







Now if you go Project properties  > Libraries and Classpath > ADF Library > Edit
You can see the lib  that you add it.

Note:
JDeveloper also makes the followng file
\Application1\ViewController\ADF_Library_Dependencies.library
where it writes all the dependencies:



which you can saafely delete.

Keep Popup open even if you navigate to another page and return or set autocanel prop

Scenario:

You are in a page where you open an af:popup
In the af:popup there is a button that navigates to another TF and
when you returned from the TF you want to have the popup open as you left it

Solution

Use autoCancel=disabled
eg
  <af:popup ... autoCancel="disabled" ... >

11 October 2010

Optional Criteria in BC and af:query

When in BC we use n ad hoc criteria to filter the results  
eg. Salary




It is the same as using Add fields in the Advance mode of af:query
eg. without advanced


Using Salary in Advance mode


App Module's method return type and parameters must implement java.io.Serializable to be exposed

If you want to expose a app modules method, then it's return type and parameters must implement java.io.Serializable.
Otherwise the wizard we used to expose the method  does not even show it.

 If you know that the Class of the return type and parameters of your method's  can be Serializable, then add "implements Serializable"  in the class declaration to continue.