af:inputFile is not calling valueChangeListener method - oracle-adf

Summarize the problem
I'm trying to upload an image to a blob in the database and have been following various blogs online to do so.
Provide background including what you've already tried
I've tried enclosing the input file on a form but I get the warning:-
"Only one af:form is supported per page. This warning later escalates to a server exception error and I can't enter said page.
Show some code
<af:panelFormLayout id="pfl1">
<f:facet name="footer"/>
<af:form id="f1" usesUpload="true">
<af:inputFile label="Label 1" id="if1" value="#NewUploadImageBean.file}"
valueChangeListener="#{NewUploadImageBean.upLoadValueChangeListener}"/>
</af:form>
</af:panelFormLayout>
I only have this one form in the entire page.
Describe expected and actual results including any error messages
Would like to the valueChangeListner to call my method. Currently I get the
ADF_FACES-60097 error which then translates to : java.lang.IllegalStateException: ADF_FACES-30124:Multiple forms detected on viewId: /test_pages/employement.jsf. Rich client currently has some limitations in dealing with multiple forms.

How to fix ADF_FACES-30124:Multiple forms detected on viewId ?
To do so remove all the af:forms inside your jsf view expecially the one containing your inputFile and add only one af:form useupload="true" at the highest view tag level :
<af:document >
<af:form usesUpload="true" id="f1">
... ALL YOUR VIEW TAGS ...
</af:form>
</af:document>

Related

page goes blank after partial refresh - xpages

I'm getting a wired behavior while uploading file.
I then, in another part of the page activate partial refresh (not related to the upload file section at all). the hole page turn blank.
i found out that it is happening only id a data source is bind to the page.
here is a sample of html:
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="document1" formName="Supplier"></xp:dominoDocument>
</xp:this.data>
<xp:fileUpload id="fileAtt" immediate="false" required="true">
</xp:fileUpload>
<xp:br></xp:br>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="computedField1" immediate="true">
</xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:text escape="true" id="computedField1"></xp:text>
</xp:view>
The File Upload control needs to be bound to a field on the datasource. Otherwise, you're asking the end user to upload an attachment without specifying where to store it, which is not an expected development approach.

Error in Jdeveloper 12.2.1.2 while upgrading application from jdeveloper 11.1.1,7,1

I was trying to upgrade my application from 11g to 12c. In that i am getting an error.
<org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl> <ViewHandlerImpl> <_isTimestampCheckEnabled> <Apache Trinidad is running with time-stamp checking enabled. This should not be used in a production environment. See the org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION property in WEB-INF/web.xml>
<org.apache.myfaces.trinidadinternal.util.FrameBustingUtils> <FrameBustingUtils> <_getFrameBustingString> <The framebusting context param 'oracle.adf.view.rich.security.FRAME_BUSTING' has been deprecated. Please change your web.xml to use 'org.apache.myfaces.trinidad.security.FRAME_BUSTING' instead. The legal values are 'always', 'never', and 'differentOrigin'. If you were setting the value of 'oracle.adf.view.rich.security.FRAME_BUSTING' to 'differentDomain', then please note that you should set 'org.apache.myfaces.trinidad.security.FRAME_BUSTING' to 'differentOrigin'.>
<oracle.adf.view> <UIXRegion> <_logNullValueMessage> <The expression "#{bindings.AddTypeBTF1.regionModel}" that was specified for the RegionModel "value" attribute of the region component with id ":pt1:r1" evaluated to null. Using an empty RegionModel instead.>
<oracle.adf.view> <UIXRegion> <_logNullValueMessage> <The expression "#{bindings.AddTypeBTF1}" evaluated to "".
The expression "#{bindings}" evaluated to "".
>
<org.apache.myfaces.trinidadinternal.style.xml.parse.StyleSheetDocument> <StyleSheetDocument> <_resolveStyleNode> <Circular dependency detected in style af|dvt-timeline>
<Sep 19, 2017, 12:48:00,384 PM IST> <Warning> <Socket> <BEA-000449> <Closing the socket, as no data read from it on 127.0.0.1:50,050 during the configured idle timeout of 5 seconds.>
This is my page
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1" title="PMS">
<af:form id="f1">
<af:pageTemplate viewId="/PMS/Template/PMSTemplate.jspx" id="pt1">
<f:facet name="Content">
<af:region value="#{bindings.AddTypeBTF1.regionModel}" id="r1"/>
</f:facet>
</af:pageTemplate>
</af:form>
</af:document>
</f:view>
</jsp:root>
This is binding of the page
<?xml version="1.0" encoding="UTF-8" ?>
<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel"
version="11.1.1.65.57" id="PMSTypeMasterPageDef"
Package="PMS.Pages">
<parameters/>
<executables>
<variableIterator id="variables"/>
<taskFlow id="AddTypeBTF1"
taskFlowId="/PMS/TaskFlows/AddTypeBTF.xml#AddTypeBTF"
activation="deferred"
xmlns="http://xmlns.oracle.com/adf/controller/binding"/>
</executables>
<bindings/>
</pageDefinition>
There is no warning in the page or else in the pagedef.
i tried to clean my application as well as removed all cache and useless stuff from my PC. Still it's not working.
I asked my colleague about this issue. they have faces the similar one. and it was solved by cleaning the application and they have restarted the Jdeveloper.
But same is not working with me.
I searched on the internet. many sites suggest that there might be no entry in the pagedef. but i can find entry of taskflow there as well.
<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.CHECK_FILE_MODIFICATION</param-name>
<param-value>false</param-value>

How to use MDS customization to add JSTL functions tag library?

I added the JSTL functions tag library into the folderViewer.jsff view in the WebCenter Portal 11.1.1.6.0 folderViewer taskflow (oracle.webcenter.doclib.view.jsf.taskflows.folderViewer), so that I can perform string operations prior to rendering the view.
I added it using the following mds:modify block in the folderViewer.jsff.xml MDS customization file:
<mds:modify element="(xmlns(jsp=http://java.sun.com/JSP/Page))/jsp:root">
<mds:attribute name="version" value="2.1"/>
<mds:attribute name="xmlns:fn" value="http://java.sun.com/jsp/jstl/functions"/>
</mds:modify>
This allows me to use the JSTL functions in EL statements, such as: startFolderPath=#{fn:replace(fn:substringAfter(item.url,'path'),'%20','%2520')}.
However, there seems to be an unintended side-effect of this in the folderViewer task flow. When there are over 50 subfolders in a folder, scrolling past the 50th subfolder and trying to navigate to one of the subfolders (i.e. navigating to subfolder #51) results in a WebCenter error page being displayed and the following error in the logs:
<Oct 28, 2013 3:10:54 PM CDT> <Error> <oracle.webcenter.webcenterapp.internal.view.webapp> <BEA-000000> <
oracle.mds.exception.MDSRuntimeException: invalid namespace http://java.sun.com/JSP/Page for prefix xmlns
invalid namespace http://java.sun.com/JSP/Page for prefix xmlns
at oracle.mds.core.MOTxnState.getDocument(MOTxnState.java:266)
at oracle.mds.core.UpdateableMOContent.getDocument(UpdateableMOContent.java:561)
at oracle.mds.core.MetadataObject.getDocument(MetadataObject.java:449)
at oracle.mds.core.MetadataObject.getDocument(MetadataObject.java:396)
...
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
>
<Oct 28, 2013 3:10:54 PM CDT> <Error> <oracle.webcenter.webcenterapp> <BEA-000000> <Internal Error (WCS#2013.10.28.15.10.54)>
If I remove the MDS customization to folderViewer.jsff.xml that adds the JSTL Functions tag library, this issue does not exist.
Does anyone know of a different way to add a new tag library via MDS customization?
Thanks,
Joe
It seems like its trying to give prefix xmlns instead of JSP
I'm just wonder if you changed the above code to the following, what will happen
<mds:modify element="jsp:root">
<mds:attribute name="version" value="2.1"/>
<mds:attribute name="xmlns:jsp" value="http://java.sun.com/JSP/Page"/>
<mds:attribute name="xmlns:fn" value="http://java.sun.com/jsp/jstl/functions"/>
</mds:modify>

ADF problems with af:validateRegExp (binding Long field)

I have a portlet application in a WebCenter env. This application is made using JSF (with the ADF implementation), so I have a field like that:
<af:inputText visible="#{CadastrarFormularioContato.showCodigoEc}"
label="#{msg.CODIGODOEC}" id="it2" required="true"
requiredMessageDetail="#{msg.INFORMECODIGOEC}"
showRequired="true"
value="#{CadastrarFormularioContato.item.cdEstabelecimento}">
<af:validateRegExp messageDetailNoMatch="#{msg.CODIGOECSOMENTENUMEROS}" pattern="^[0-9]{1,}$"/>
<af:convertNumber type="number"/>
</af:inputText>
But, when I invoke the form submit i receive the follow error:
javax.portlet.faces.BridgeException: java.lang.IllegalArgumentException: 'value' is not of type java.lang.String.
My Object.longField is:
private Long longField
(with its getters/setters)
I try to use convert, convertNumber etc but with no sucess.
The problem is about the "validateRegExp" tag (if i remove it, works) So, why?
Any suggestion?
The validateRegExp only accepts Strings. If you can change the java class, then adding a String field to shadow the Long is an easy fix. If not, you can write your own regex validator.

How to detect broken WPF Data binding?

While trying to answer a question in the vicinity 'Unit Testing WPF Bindings' I had the following niggling question..
What's the best way to find if you have WPF Data Binding wiring setup incorrectly (or you just broke something that was wired up correctly) ?
Although the unit-testing approach seems to be like Joel's 'ripping off your arm to remove a splinter'.. I am looking around for easier less Overhead ways to detect this.
Everyone seems to have committed themselves to data binding in a big way with WPF.. and it does have its merits.
In .NET 3.5 it was introduced a new way to specifically output tracing information about specific data bindings.
This is done through the new System.Diagnostics.PresentationTraceSources.TraceLevel attached property that you can apply to any binding or data provider. Here is an example:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
Title="Debug Binding Sample"
Height="300"
Width="300">
<StackPanel>
<TextBox Name="txtInput" />
<Label>
<Label.Content>
<Binding ElementName="txtInput"
Path="Text"
diag:PresentationTraceSources.TraceLevel="High" />
</Label.Content>
</Label>
</StackPanel>
</Window>
This will put trace information for just that particular binding in Visual Studio's Output Window, without any tracing configuration required.
Best I could find...
How can I debug WPF Bindings? by Beatriz Stollnitz
Since everyone can't always keep one eye on the Output Window looking for Binding errors, I loved Option#2. Which is add this to your App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.Windows.Data" switchName="SourceSwitch" >
<listeners>
<add name="textListener" />
</listeners>
</source>
</sources>
<switches>
<add name="SourceSwitch" value="All" />
</switches>
<sharedListeners>
<add name="textListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="GraveOfBindErrors.txt" />
</sharedListeners>
<trace autoflush="true" indentsize="4"></trace>
</system.diagnostics>
</configuration>
Pair that up with a good regex scan script to extract out relevant info, that you can run occasionally on the GraveOfBindErrors.txt in your output folder
System.Windows.Data Error: 35 : BindingExpression path error: 'MyProperty' property not found on 'object' ''MyWindow' (Name='')'. BindingExpression:Path=MyProperty; DataItem='MyWindow' (Name=''); target element is 'TextBox' (Name='txtValue2'); target property is 'Text' (type 'String')
I use the solution presented here to turn binding errors into native Exceptions: http://www.jasonbock.net/jb/Default.aspx?blog=entry.0f221e047de740ee90722b248933a28d
However, a normal scenario in WPF bindings is to throw exceptions in case the user input cannot be converted to the target type (for instance, a TextBox bound to a integer field; the input of a non-numeric string results in a FormatException, the input of number that is too large results in an OverflowException). A similar case is when the Setter of the source property throws an exception.
The WPF way of handling this is via ValidatesOnExceptions=true and ValidationExceptionRule to signal the user the supplied input is not correct (using the exception message).
However, these exception are also send to the output window and thus 'caught' by the BindingListener, resulting in an error...clearly not the behaviour you'd want.
Therefore, I expanded the BindingListener class to NOT throw an Exception in these cases:
private static readonly IList<string> m_MessagesToIgnore =
new List<String>()
{
//Windows.Data.Error 7
//Binding transfer from target to source failed because of an exception
//Normal WPF Scenario, requires ValidatesOnExceptions / ExceptionValidationRule
//To cope with these kind of errors
"ConvertBack cannot convert value",
//Windows.Data.Error 8
//Binding transfer from target to source failed because of an exception
//Normal WPF Scenario, requires ValidatesOnExceptions / ExceptionValidationRule
//To cope with these kind of errors
"Cannot save value from target back to source"
};
Modified lines in public override void WriteLine(string message):
....
if (this.InformationPropertyCount == 0)
{
//Only treat message as an exception if it is not to be ignored
if (!m_MessagesToIgnore.Any(
x => this.Message.StartsWith(x, StringComparison.InvariantCultureIgnoreCase)))
{
PresentationTraceSources.DataBindingSource.Listeners.Remove(this);
throw new BindingException(this.Message,
new BindingExceptionInformation(this.Callstack,
System.DateTime.Parse(this.DateTime),
this.LogicalOperationStack, int.Parse(this.ProcessId),
int.Parse(this.ThreadId), long.Parse(this.Timestamp)));
}
else
{
//Ignore message, reset values
this.IsFirstWrite = true;
this.DetermineInformationPropertyCount();
}
}
}
You can use the trigger debugging feature of WPF Inspector. Just download the tool from codeplex and attach it to your running app. It also shows binding errors on the bottom of the window.
Very useful tool!
Here's a useful technique for debugging/tracing triggers effectively. It allows you to log all trigger actions along with the element being acted upon:
http://www.wpfmentor.com/2009/01/how-to-debug-triggers-using-trigger.html
This was very helpful to us but I wanted to add to those who find this useful that there is a utility that Microsoft provides with the sdk to read this file.
Found here: http://msdn.microsoft.com/en-us/library/ms732023.aspx
To open a trace file
1.Start Service Trace Viewer by using a command window to navigate to your
WCF installation location (C:\Program
Files\Microsoft
SDKs\Windows\v6.0\Bin), and then type
SvcTraceViewer.exe. (although we found ours in \v7.0\Bin)
Note: The Service Trace Viewer tool
can associate with two file types:
.svclog and .stvproj. You can use two
parameters in command line to register
and unregister the file extensions.
/register: register the association of
file extensions ".svclog" and
".stvproj" with SvcTraceViewer.exe
/unregister: unregister the
association of file extensions
".svclog" and ".stvproj" with
SvcTraceViewer.exe
1.When Service Trace Viewer starts, click File and then point to Open.
Navigate to the location where your
trace files are stored.
2.Double-click the trace file that you want to open.
Note: Press SHIFT while clicking
multiple trace files to select and
open them simultaneously. Service
Trace Viewer merges the content of all
files and presents one view. For
example, you can open trace files of
both client and service. This is
useful when you have enabled message
logging and activity propagation in
configuration. In this way, you can
examine message exchange between
client and service. You can also drag
multiple files into the viewer, or use
the Project tab. See the Managing
Project section for more details.
3.To add additional trace files to the collection that is open, click File
and then point to Add. In the window
that opens, navigate to the location
of the trace files and double-click
the file you want to add.
Also, as for the filtering of the log file, we found these this link extremely helpful:
http://msdn.microsoft.com/en-us/library/ms751526.aspx
For anyone like me looking for a pure programmatic way of enabling all WPF Tracing at a given Trace Level, here is a piece of code that does it. For reference, it's based on this article: Trace sources in WPF.
It doesn't requires a change in the app.config file, and it does not require to change the registry either.
This is how I use it, in some startup place (App, etc.):
....
#if DEBUG
WpfUtilities.SetTracing();
#endif
....
And here is the utility code (by default it sends all Warning to the Default Trace Listener):
public static void SetTracing()
{
SetTracing(SourceLevels.Warning, null);
}
public static void SetTracing(SourceLevels levels, TraceListener listener)
{
if (listener == null)
{
listener = new DefaultTraceListener();
}
// enable WPF tracing
PresentationTraceSources.Refresh();
// enable all WPF Trace sources (change this if you only want DataBindingSource)
foreach (PropertyInfo pi in typeof(PresentationTraceSources).GetProperties(BindingFlags.Static | BindingFlags.Public))
{
if (typeof(TraceSource).IsAssignableFrom(pi.PropertyType))
{
TraceSource ts = (TraceSource)pi.GetValue(null, null);
ts.Listeners.Add(listener);
ts.Switch.Level = levels;
}
}
}
My suggestion at 2021:
The Best way is to use Benoit Blanchon small library from Nuget
His original post at here: https://stackoverflow.com/a/19610384/6296708
His GitHub link and more info about how to use it + Nuget command: https://github.com/bblanchon/WpfBindingErrors
Its features (until now!):
throw exception on binding errors (+ line number)
If source Variable throw any exceptions, this library will catch it and show it.
Unit Test supports too!
Happy Coding!

Resources