Show the User a Record Count

February 26th, 2007

I came across this in the JDeveloper Help file.  This will display something similar to Record 1-10 of 100.  Notice that if the estimated row count is less than the range size (rowcount 5, range size 10) the result is Record 1 of 5.  Also, I had to write some logic here for the paging when a user is simply paging by NextSet.  If they page all of the way in this fashion and the last page shows less than the range size, the result would have been like Record 1-110 of 98.  To repair this, I check if the range start plus range size is more than estimated row count, I use the estimated row count, resulting in Record 1-98 of 98.  This will give the use an idea of how many rows are paged, and where they are in the paging.

<c:choose>
  <c:when test=”${bindings.AllContractsView1Iterator.estimatedRowCount > 0}”>
    <c:choose>
       <c:when test=”${bindings.AllContractsView1Iterator.estimatedRowCount < bindings.AllContractsView1Iterator.rangeSize}”>
           Record <c:out value=”${bindings.AllContractsView1Iterator.rangeStart + 1}”/> of <c:out value=”${bindings.AllContractsView1Iterator.estimatedRowCount}”/> 
      </c:when>
      <c:when test=”${bindings.AllContractsView1Iterator.rangeStart + bindings.AllContractsView1Iterator.rangeSize > bindings.AllContractsView1Iterator.estimatedRowCount}”>
           Record <c:out value=”${bindings.AllContractsView1Iterator.rangeStart + 1}”/>-<c:out value=”${bindings.AllContractsView1Iterator.estimatedRowCount}”/> of <c:out value=”${bindings.AllContractsView1Iterator.estimatedRowCount}”/>                  
     </c:when>                  
     <c:otherwise>
         Record <c:out value=”${bindings.AllContractsView1Iterator.rangeStart + 1}”/>-<c:out value=”${bindings.AllContractsView1Iterator.rangeStart + bindings.AllContractsView1Iterator.rangeSize}”/> of <c:out value=”${bindings.AllContractsView1Iterator.estimatedRowCount}”/>
     </c:otherwise>   
</c:choose>
                
              </c:when>
              <c:otherwise>
                  
              </c:otherwise>
            </c:choose>

Override those pesky JBO Mandatory Error Messages in the EnityImpl

February 26th, 2007

I have often times had issues getting an error message customized properly for a mandatory attribute of an Entity.  After much research and testing of my own, I came to one conclusion: Override the message in the Entity’s validateEntity method.  However, I took this one step further and create a subclass (StandardEntityImpl) of the EntityImpl class that will perform this operation.  By doing this, now any new entities (from my tables) will now be a subclass of my new  StandardEntityImpl.  I can now get the “code once use everywhere” method. 

 Here is the code of my StandardEntityImpl:

package sift.model;

import com.sun.java.util.collections.ArrayList;

import oracle.jbo.AttrValException;
import oracle.jbo.JboException;
import oracle.jbo.server.EntityDefImpl;
import oracle.jbo.server.EntityImpl;

import sift.exceptions.AttrRequiredException;  // My own custom exception for Required Attributes

import sift.validations.CommonJboMessageBundle;  // My Message Bundle for my custom exception

abstract class StandardEntityImpl extends EntityImpl {

    abstract EntityDefImpl getInstanceDefinitionObject();  // this has to be overridden in the child class, just copy the static method and remove the static part of the call

    /**Add Entity validation code in this method.
     */
    protected void validateEntity() {
       
        try {
         super.validateEntity();
        } catch (JboException jboe) {
          jboe = (JboException)processException(jboe);
        
          throw jboe;
        }
       
               
    }

    protected Exception processException(Exception ex) {
       if (ex instanceof JboException) {          
           JboException jboex = (JboException)ex;         
          
           if (jboex instanceof AttrValException) {
               if (jboex.getErrorCode().equals(”27014″)) {
                 if (jboex instanceof AttrRequiredException) {
                   // Do nothing, error is already of the AttrRequiredException type (my exception)
                 } else {        
                   AttrValException attrValException = (AttrValException)jboex;
                   String [] params = {getInstanceDefinitionObject().findAttributeDef(attrValException.getAttrName()).getUIHelper().getLabel(getDBTransaction().getSession().getLocaleContext())}; // You must define the label for the attribute in the Entity definition.                                   
                   AttrRequiredException attrReqException = new AttrRequiredException(
                                                                 CommonJboMessageBundle.class,
                                                                 getInstanceDefinitionObject().getFullName(),
                                                                 attrValException.getAttrName(),
                                                                 attrValException.getAttrValue(),
                                                                 params); // Creating my custom error message, do as you will here
                  attrReqException.setExceptions(jboex.getExceptions());
                  jboex = attrReqException;
                  ex = jboex;
                 }
               }
           }               
          
           Object[] details = jboex.getDetails();                    
          
           if ((details != null) && (details.length > 0)) {
               for (int i=0, count=details.length; i                    details[i] = processException((Exception)details[i]);
               }
              
               ArrayList arrayListExceptions = new ArrayList(details.length);
               for (int i = 0; i < details.length; i++)  {
                   arrayListExceptions.add(details[i]);
               }                       
               ((JboException)ex).setExceptions((Throwable[])arrayListExceptions.toArray(new Throwable[arrayListExceptions.size()]));
           }
       }
      
       return ex;
    }
}

 

That’s pretty much it!  You will notice that I am simply replacing the JBO Oracle standard error message with my own custom message.  Now for actual business rules and their messages, code these in the set methods or using the validators.  This will just correct the Mandatory error codes.  Mandatoryness, if there is such a word, is checked in the entity validation, not at the attribute level.

Correcting Run-time when Connected Through a VPN Installed as a NIC

January 17th, 2007

I have seen many forums where individuals have complained about a problem where the JDeveloper run-time does not excute properly when connected through a VPN.  In most cases, the error that is received is “Connection timed out.”  This can be at fault due to having two Network Interface Cards installed.  In my case, I had a second NIC installed because my VPN software installs itself as a virtual NIC.  After reviewing the JDeveloper run-time code, I found that the issue was in the sendMessage method of the Oc4jNotifier class.  The following code was the issue point:

InetAddress localhost = InetAddress.getLocalHost();

When I ran a test of this statement only while connected through my VPN software, I found that the IP address returned from this statement was a non-routeable IP address.  This is because the Java code above appears to take the computer name and pings it to resolve.  So, a change was made to convert the code to:

InetAddress localhost = InetAddress.getByName(”localhost”);

By doing so, now the IP address returned is the loopback address (127.0.0.1), because the “localhost” name itself is now used, not the computer’s name.  One draw back to this solution is that if this code is used on an operating system that does not use “localhost” or does not have it defined, the code will fail.  However, since most of the world uses Windows, I didn’t see much of an issue for most users.

Files needed to Correct VPN Issue with JDeveloper 10.1.3

Welcome to My JDeveloper Blog

January 16th, 2007

Welcome to My JDeveloper Blog! I will have some interesting information posted here later for others to review and see some workarounds I have either found or created for the JDeveloper product supplied by Oracle. You can ask a question here, but I don’t promise I will have the answer. This blog is more of a home for my knowledge and to possibly learn from others.