Skip to main content

Posts

Showing posts from 2010

ADF Popup buttons rendred outside the dialog - IE

If you have custom buttons in your popup that are right aligned and they are toolbarbuttons they may render outside the dialog in Internet Explorer. Just remove the af:toolbar tag and make the buttons af:commandButton instead of af:commandToolbarButton and they should behave. Also remeber that commandToolbarButton partial submit is set to true by default.

JBO-25013: TooManyObjectsException

oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key oracle.jbo.Key[Key null ]. Ok so for you it may be trying to insert a duplicate record this should explain your problem (also check trigger they could be the cause.) NOTE: You can also try to create a new duplicate EO if you have a page with two VO's using the same EO. This could sort your problems. For me I needed to add a launch listener on my LOV and clear the cache of my vo. LOV <af:inputListOfValues id="NameId" popupTitle="#{bindings.Name.hints.label}" value="#{bindings.RolName1.inputValue}" label="#{bindings.RolName1.hints.label}" model="#{bindings.RolName1.listOfValuesModel}" required="#{bindings.RolName1.hints.mandatory}" columns="#{bindings.RolName1.hints.displayWidth}" shortDesc="#{bindings.RolName1.hints.tooltip}" launchPopupListener="#{backingBeanScope.backingBean.launchPop

***** adf secret password

Ok so my secret password text inputs always changed to ****** after submit (not the number of characters I typed in) on error on the client. Though this was a bit weird so I checked it out and found that this is ADF default behaviour. The only way to change this is to create your own renderer so I left it as it was. Also changing this in any way will make your app less secure.

ADF programmatic disabled

I am creating dynamic links and here is something useful I used for programmatic creatin of the links. uiCompnent.setValueExpression( "disabled", JSFUtils.getValueExpression( "#{bindings.MyVOIterator.estimatedRowCount == 0}", Boolean.class)); public static ValueExpression getValueExpression( String expression, Class clazz){ FacesContext ctx = FacesContext.getCurrentInstance(); ELContext elCtx = ctx.getELContext(); Application app = ctx.getApplication(); return app.getExpressionFactory().createValueExpression( elCtx, expression, clazz); }

Util code

public static MethodExpression getMethodExpression( String expr, Class returnType, Class[] argTypes){ FacesContext fc = FacesContext.getCurrentInstance(); ELContext elctx = fc.getELContext(); ExpressionFactory elFactory = fc.getApplication().getExpressionFactory(); return elFactory.createMethodExpression( elctx, expr, returnType, argTypes); } public static javax.faces.el.MethodBinding getMethodBinding( String expr, Class[] argTypes){ FacesContext fc = FacesContext.getCurrentInstance(); ELContext elctx = fc.getELContext(); return fc.getApplication().createMethodBinding(expr, argTypes); } SetPropertyListener listener = new SetPropertyListener( ActionEvent.class.getName()); listener.setFrom(link.getRoute()); listener.setValueExpression("to", JSFUtils.getValueExpression("#{pageFlowScope.route}", String.class)); action.addActionListener(listener); AdfFacesContext.getCurrentInstance().getPageFlowScope() .put("route", lin

ADF weblogic remote deployment problem -

Use the t3 protocol (ProtocolException Tunneling problem) not http for remote deployments and dont forget the -upload flag (Unable to access application source information in)! Example: <java classname="weblogic.Deployer" fork="true" failonerror="true" classpath="/oracle/jdeveloper/weblogiclibrary/weblogic.jar"> <arg value="-library"/> <arg value="-upload"/> <arg value="-adminurl"/><arg value="t3://$wlHost:7001"/> <arg value="-username"/><arg value="weblogic"/> <arg value="-password"/><arg value="weblogic1"/> <arg value="-source"/><arg value="/deploy/application.ear"/> <arg value="-targets"/><arg value="DefaultServer"/> <arg value="-deploy"/> </java>

ADF Date convert secondary pattern

This will try the second pattern if there is an error with the first. This should sort out most situations you need else you will need to write a custom tag. <af:convertDateTime pattern="yyyyMMdd" secondaryPattern="yyyy-MM-dd" /> NOTE: interesting javascript override Java [custom converter] public class YourDateConverter extends DateTimeConverter implements ClientConverter { public Object getAsObject( FacesContext facesContext, UIComponent uiComponent, String string){//do convert here} public String getAsString( FacesContext facesContext, UIComponent uiComponent, Object object) {//do convert here} public java.lang.String getClientConversion( javax.faces.context.FacesContext fc, javax.faces.component.UIComponent c){ String conv = super.getClientConversion(fc, c); return "new YourDateTimeConverter('dd/MM/yyyy',null,'01/11/2010','DATE')"; } Javascript: function YourDateTimeConverter( pattern, locale

ADF Exact custom filters

Step 1) Add your custom filter to the column filter facet. <f:facet name="filter"> <af:selectBooleanCheckbox value="#{backingBean.customfilter}" id="id99"/> </f:facet> Step 2) Create the getters and setters in your backing bean public Boolean getCustomfilter(){ Boolean returnobj = null; Object filterValue = super.getFilterValue("AttributeName"); if (filterValue != null){ returnobj = ("Y".equalsIgnoreCase(filterValue.toString())) ? Boolean.TRUE : Boolean.FALSE; } return returnobj; } public void setCustomfilter(Boolean deletefilter){ String value = filter == null ? null : (deletefilter) ? "Y" : "N"; super.setFilterValue(value, "AttributeName"); } NOTE: Dates Filtered Dates with timestamps in ADF dont work very nicely if you just want to filter by date. So your can modify the date f

ADF VO criteria performance problem

One of our screens backed by a huge table was slow. (+1 10 seconds just for the query alone). And here is what I found out: Our query with a criteria to filter the tablename and key < 1 second SELECT a.ele_name AS ELEMENT_NAME, a.pk AS PKEY, a.audit_result AS AUDIT_RESULT FROM audit a, mds_users u WHERE a.user = u.code AND a.ele_name = :tablename AND a.pk = :key ADF converted query 12 seconds looks something like this: SELECT * FROM (SELECT a.ele_name AS ELEMENT_NAME, a.pk AS PKEY, a.audit_result AS AUDIT_RESULT FROM audit a, users u WHERE a.user = u.code) QRSLT WHERE ( ( ( (UPPER(PKEY) = UPPER(:key) ) AND (UPPER(ELEMENT_NAME) = UPPER(:tablename) )) ) ) ORDER BY AUDIT_DATE DESC So I remove the UPPER from the query and all was good. Note to self always check this or you will suffer. (Ignore case check box in the criteria if you are looking for this)

Auto Submit button for page fragements

If your region is encased in a form you will have no access to the defaultCommand on your af:form. Try adding a subform to your fragement (jsff) and use its defaultCommand - note this will affect your naming. This should also work for popup buttons. ie. after your <jsp:root <af:subform defaultCommand="submitButton" id="s3">    ... your code </af:subform>

ADF tree menu code

We have a tree menu that works of a hierarchical structure in the DB. Note you must have seperate iterators for the tree and the view. It will disclose and select an item in your tree based on a selection. This can be modified in various ways to get your trees jumping through hoops. So here is the code so I dont loose it: <af:tree value="#{bindings.TreeRootMenuVO2.treeModel}" var="node" selectionListener="#{pageFlowScope.TreeBean.selectionListener}" rowSelection="single" id="t1" binding="#{pageFlowScope.TreeBean.menuTree}" contentDelivery="immediate" fetchSize="500"> <f:facet name="nodeStamp"> <af:outputText value="#{node}" id="ot1"/> </f:facet> </af:tree> <af:commandToolbarButton text="Find Node" id="cb5" actionListener="#{pageFlowScope.TreeBean.findInTree}"/> <af:commandToo

Traversing a hierarchical oracle tree in SQL backwards

So I have a menu table with a parent child relationship menu_id, menu_name, parent_id and I want to retrieve the whole branch that Menu Child E is in. ie all its ancestors. The result should be ordered from the root. So given: Root (id:0 parent_id: null) Menu Parent A(id:1 parent_id: 0) Menu Child B(id:2 parent_id: 1) Menu Parent C(id:3 parent_id: 0) Menu Child D(id:4 parent_id: 3) Menu Child E(id:5 parent_id: 3) I want: Root (id:0 parent_id: null) Menu Parent C(id:3 parent_id: 0) Menu Child E(id:5 parent_id: 3) select m.menu_id, m.menu_name, m.parent_id from MENU m start with m.menu_id = 5 connect by prior m.parent_id = m.menu_id ORDER BY LEVEL DESC;

The DocumentChange is not configured to be allowed for the component:

<FilteredPersistenceChangeManager><_addDocumentChangeImpl> The DocumentChange is not configured to be allowed for the component: RichTable[org.apache.myfaces.trinidad.component.UIXTable$RowKeyFacesBeanWrapper@fdf42c, id=audTab] This is what I understand this message to mean: If MDS is configured a request is send to the FilteredPersistenceChangeManager wich then does a check to see if the component is configured. If the change is not configured then the change will then be written to the users session and you will get the above message in your logs. To configure the MDS stuff in your adf application : 1) Open adf-config.xml - located in Application Resources < ADF META-INF dir. 2) On the View tab click the green plus button and select the component that the error is complaining about. 3) Configure as needed.

Auto Focus in ADF

still to fill in details but heres the idea -- bind query to backing bean -- get Id from bound query and inject some javascript with the id. public void focus(UIXComponent comp) { StringBuilder script = new StringBuilder(); FacesContext context = FacesContext.getCurrentInstance(); script.add("var elem = document.getElementById(").append(comp.getClientId(context)).append("); if (elem != null) {elem.focus();}"); Service.getRenderKitService(context, ExtendedRenderKitService.class).addScript(context, script.toString()); } -- viola ok after some pain here is the javascript function that works on ie and firefox function focusField(elementId) { var comp = document.getElementById(elementId); if (comp != null) { comp.focus(); comp.select(); } } NOTE: On some screens the auto focus does not work because the component does not have an id or children(has not been initialized etc) for this just run the method bound to the value attribute on component aft

ADF Excel export

In adf if you export your tables that contain lov inside the index or id is exported and not the selected item value. If your table is read only change your existing table column from eg: <af:outputText value="#{row.bindings.Field.items[row.bindings.Field.inputValue].label}" id="ot3"/>

Me and my ADF

--Just a random set of opinions read no further if you are looking for technical info. Ok so I have been working with ADF for 8 months now (have worked with SOA suite before) and here are a couple of rants and findings: Development speed etc: The initial learning curve in VERY steep. Get help - we had an adf expert help us out - invaluable. Get the adf source code - it will help you. Like any framework you need to write a bit of framework extension code It is NOT just drag and drop dev if you want anything custom. Try to get things right from the start or you will end up redoing a lot and it is not very "refactoring" friendly. Forms devs will have to get a LOT of training to use this. (they will have to learn java and ADF unless you run a sweat shop dev process) Hire a very very compentant java dev before switching over from forms. Having a lot of logic in pl\sql with this framework may not be a bad thing. Try to do as little custom stuff as possible Once you h

Almost foolproof ADF Oracle proxying

1) Create a common application model (this also sets up the oracle users in the context just for auditing) @Override protected void prepareSession(Session session){ super.prepareSession(session); try{ String userName = ADFContext.getCurrent().getSecurityContext().getUserName(); String host = ((HttpServletRequest)ADFContext.getCurrent().getEnvironment().getRequest()).getRemoteHost(); String ip = ((HttpServletRequest)ADFContext.getCurrent().getEnvironment().getRequest()).getRemoteAddr(); if (userName != null){ setupSessionInfo(getDBTransaction(), host, ip, userName); } proxyUser(getDBTransaction()); //this is done because of a crappy weblogic caching error clearPoolCache(getDBTransaction()); } catch (Exception e){ session = null; System.out.println("------> Error in user proxy"); e.printStackTrace(

ant and ojdeploy

oracle.jdeveloper.ojdeploy.path=/Oracle/Middleware/jdeveloper/jdev/bin/ojdeploy application.name=Common <target name="buildJar"> <exec executable="${ojdeploy.path}" dir="${basedir}/${application.name}"> <arg line="-workspace ${basedir}/${application.name}/${application.name}.jws"/> <arg line="-project ${application.name}"/> <arg line="-profile ${application.name}"/> <arg line="-nodatasources"/&gt <arg line="-forcerewrite"/> <arg line="-basedir ${basedir}/${application.name}"/> </exec> </target>

UnsupportedCallbackException: Accessing the HttpServletRequest from a custom auth provider

There could be more than one cause of this problem but here is what cause it for me: My custom provider was the first provider in the list and was set to sufficient. I got an UnsupportedCallbackException when I tried to use the ContextHandlerCallback to retrieve the request in my provider. This was due to the fact that weblogic log in was using my provider and it uses the SimpleCallbackHandler (boo hiss). Here is my code: (I throw an login exception and fail the login if the callbacks are null for my login) private Callback[] getCallbacks() throws LoginException{ Callback[] callbacks = new Callback[3]; // need one for the user name callbacks[CALLBACK_USERNAME_POSITION] = new NameCallback("username: "); callbacks[CALLBACK_PASSWORD_POSITION] = new PasswordCallback("password: ", false); callbacks[CALLBACK_CONTEXT_POSITION] = new ContextHandlerCallback(); try{ callbackHandler.handle(callbacks); } catch (IOException e){ e.

Case Insensitive Filter

On the column just set the filterFeatures attribute to caseInsensitive CODE ALTERNATIVE 1) Map your querylistener and table binding to methods in your backing bean. 2) Implement the above mentioned methods and so what you need to the filter: public void queryListener(QueryEvent queryEvent){ FilterableQueryDescriptor des = (FilterableQueryDescriptor)getModuleTable().getFilterModel(); Map _criteriaMap = des.getFilterCriteria(); Set featureSet = new HashSet(); featureSet.add(FilterableQueryDescriptor.FilterFeature.CASE_INSENSITIVE); Iterator criteriaIter = _criteriaMap.keySet().iterator(); Map filterFeatures = new HashMap(); while (criteriaIter != null && criteriaIter.hasNext()){ String keyCr = (String)criteriaIter.next(); ((HashMap)filterFeatures).put(keyCr, featureSet); } des.setFilterFeatures(filterFeatures); JSFUtils.invokeMethodE

Back button and connection leaks

If your back button behaves badly or connections are not closed when you close the browser and leaky. On your application module try checking "Disconnet Application Module Upon Release" this solved our problem. (Click on your AM, goto configurations, click on the Pooling and scalibility tab)

java.lang.IllegalStateException: ADF_FACES-60003:Component with ID not registered for Active Data

This was hard to fix: if anyone wants the code just ask. Or if you have a better solution please post comment. Once excel export has been clicked if we navigate around using ppr to refresh the region we get this error. I was forced to create an export handler tag wich forces the export to happen in a new window. Because this page is getting some hits here is some of the code (also use this method for pdf export): Button with new listener: (xmlns:new="http://za.co.company/adf/faces/common/my" in your jsp:root) <af:commandToolbarButton text="Export" id="ctb1" immediate="true" partialSubmit="true" icon="images/excel.jpg"> <new:myExportCollectionActionListener exportedId="audTab" type="excelHTML" filename="audit.xls" title="Audit"/> </af:commandToolbarButton> TAG: import oracle.adfinternal.view.faces.export.ExportCollectionActionListener; import oracle.adfin

JBO Exception: could not validate all transctions

1) Enable logging: on your view project goto propeties (right click). Click Run/Debug/Profile. Edit default. add these Java Options: -Djbo.debugoutput=console -Ddatasource.verbose=true 2) Make sure that the data types match if you are programmatically creating rows etc. - ie dont use java.util.Date use java.sql.Date.

ADF QA

Q) Where do I add a managed bean or a view? adfc-config Q) Where can I add a phase listener? A) faces-config.xml Q) My BC stuff is not showing up on the screen: Check that you have configured your security setting correctley: 1) Application Resources\Descriptors\META-INF 2) Open jazn-data.xml 3) Click on ADF Policies tab 4) Make sure your flow and page have rights (to test just add all rights (green plus button) to valid_user)

JSF Phase Listener for ADF

Make sure you hook into the After Phase method on RESTORE_VIEW otherwise the adf context will not have been initialized. public void afterPhase(PhaseEvent phaseEvent) {    System.out.println("___________________________________ -after phase is logged in " + isLoggedIn()); } private boolean isLoggedIn() {     if (ADFContext.getCurrent() == null ||     ADFContext.getCurrent().getSecurityContext() == null ||     ADFContext.getCurrent().getSecurityContext().getUserName() == null ||     ANONYMOUS_USERNAME.equalsIgnoreCase(ADFContext.getCurrent().getSecurityContext().getUserName()))     {         return false;     }     ADFContext.getCurrent().getSecurityContext().getUserName());     return true; }

ORA-03115 typo

ORA-03115: Unsupported network datatype or representation - dont do the following: (send the query in on creation and execution) statement = transaction.createPreparedStatement( query , DBTransaction.DEFAULT); ResultSet resultset = statement.executeQuery( query ); What was I thinking...

Teamcity build error

I am having a problem with Teamcity not building my builds, if we kick of the build the history is not updated but it runs through. going to upgrade to 5.1 and keep the configuration. hey well.

Oracle ADF

My thinking so far after one day of use and no training is a project team for ADF can include you forms developers but you really need one or two excellent java developer to get through.

Weblogic Custom Authentication Provider Error

If you are not getting your login exception set in javax.servlet.error.exception : try reordering your custom provider to the top of the provider list in the Weblogic Admin Console. Just a quick note: If you are having a hard time propogating the cause of your weblogic errors that are thrown from your custom provider try this before you throw them: protected static void throwException(boolean propagateCauseForLoginException, LoginException e, Throwable cause) throws LoginException { if (propagateCauseForLoginException) { e.initCause(cause); } throw e; }