need help for fixing selectonechoice error in ADF - oracle-adf

i have a selectonechoice with three values :A,B,C but i am getting following error on its change event:
<SimpleSelectOneRenderer> <_getSelectedIndex> Could not find selected item matching value "B" in RichSelectOneChoice[UIXEditableFacesBeanImpl, id=soc1]
My selectonechoice is configured as :
<af:selectOneChoice label="Condition Codes :" id="soc1"
valueChangeListener="#{myManageBean.onCondCodeChg}"
binding="#{myManageBean.propConditionCode}"
autoSubmit="true" valuePassThru="true"
unselectedLabel="Please Select"">
<f:selectItems value="#{myManageBean.conditionCodes}" id="si1"/>
</af:selectOneChoice>
Pls help!!!! where am i wrong ?

The issue is because even after the value is set, somehow the it's being overwritten by null value.
For me, the issue got solved by using component.resetValue() in the corresponding bean after the setter is called and value is set.

use code bellow for you problem
<f:selectItems value="#{myManageBean.conditionCodes}" id="si1"/>

Related

af:inputFile is not calling valueChangeListener method

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>

ADF remove required asterisk

I have a panelLabelAndMessage containing inputComboboxListOfValues and outputText. The LOV is a mandatory field and hence it has the asterisk beside it. But I have changed simple property to true as I did not want to show label of LOV ans assigned the same label to panelLabelAndMessage. Also changed showrequired property to true for the asterisk. But now the LOV field is also showing asterisk which is undesirable. Any way to remove the star mark but still have the model level validation in place.
I do not want to use required property of LOV.
The code for my label and fields is as below.
<af:panelLabelAndMessage label="#{bindings.Department.label}"
id="plam1"
showRequired="#{bindings.Department.hints.mandatory}">
<af:panelGroupLayout id="pgl1" layout="horizontal">
<af:inputComboboxListOfValues id="DepartmentId"
popupTitle="Search and Select: #{bindings.DepartmentId.hints.label}"
value="#{bindings.DepartmentId.inputValue}"
model="#{bindings.DepartmentId.listOfValuesModel}"
columns="#{bindings.DepartmentId.hints.displayWidth}"
shortDesc="#{bindings.DepartmentId.hints.tooltip}"
required="#{bindings.DepartmentId.hints.mandatory}"
autoSubmit="true"
binding="#{backingBeanScope.BackingBean.departmentLov}"
valueChangeListener="#{backingBeanScope.BackingBean.onSelectDepartment}">
<f:validator binding="#{bindings.DepartmentId.validator}"/>
<af:convertNumber groupingUsed="false"
pattern="#{bindings.DepartmentId.format}"/>
</af:inputComboboxListOfValues>
<af:spacer width="10" height="10" id="s1"/>
<af:outputText value="#{bindings.DepartmentName.inputValue}" id="ot1"
partialTriggers="DepartmentId"
binding="#{backingBeanScope.BackingBean.DepartmentName}"/>
</af:panelGroupLayout>
</af:panelLabelAndMessage>
To answer to core question (can you remove the asterisk ): Yes, by using ADF Skinning.
Some examples:
.hideRequired af|selectOneChoice::label af|panelFormLayout::label-cell .AFRequiredIconStyle,
.hideRequired af|panelFormLayout::label-cell .AFRequiredIconStyle,
.hideRequired af|selectOneChoice::label .AFRequiredIconStyle
{
display:none ;
}
Note that we add hideRequired as a styleClass to the component (you can give it an other name).
The one you will probably need to use is:
.hideRequired af|inputComboboxListOfValues::label .AFRequiredIconStyle
{
display:none;
}
Remove required property, the validation will still fire for LOV.
But since you have skipValidtion set to true therefore the model level validation will also not fire.
Here is how you implement required field validation without using required="true" or model level validation in Jdeveloper 11.1.2.* or higher, as this solution does not works for versions older than JSF2.0
Create a validator method in your managed bean, or if you want to reuse the validator then create a custom validator for your application.
public void requiredFieldValidator(FacesContext facesContext, UIComponent uIComponent, Object object) {
if (null == object) {
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "This field can not be empty",
null));
}
else{
if(object.toString().trim().equals("")){
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "This field can not be empty",
null));
}
}
}
Use this method as your lov validator
<af:inputListOfValues label="Lov1" popupTitle="Search and Result Dialog" id="ilov1"
validator="#{pageFlowScope.mBean.emailValidator}"/>
More importantly, to make validator works on empty fields, set javax.faces.VALIDATE_EMPTY_FIELDS to true in your web.xml
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>true</param-value>
</context-param>

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.

ibatis - where to place the <cacheModel> tag?

I have the map config file like this
<sqlMap ..............>
<alias>
<typeAlias ......../>
</alias>
<statements>
....
<sql>....</sql>
<select cacheModel="cache-select-all">....</select>
<update>...</update>
<procedure>...</procedure>
.....
</statements>
<parameterMaps>
<parameterMap>....</parameterMap>
</parameterMaps>
<cacheModel id="cache-select-all" type="LRU" readOnly="true" serialize="false">
<flushInterval hours="24"/>
<flushOnExecute statement="InsertIOs"/>
<!--<property name="CacheSize" value="1000"/>-->
</cacheModel>
</sqlMap>
I am using ibatis (.net, if that matters) and i have one question: where to place the tags? is There a or because placing it like i did, in the statements seems not to work. What am i doing wrong?
You must reference the cacheModel you defined inside a statement tag as shown in the following link:
http://ibatis.apache.org/docs/dotnet/datamapper/ch03s08.html
Before you use it in the select statement. Order does matter here. Otherwise sql map parser wouldn't be able to validate your sql map.

In Ibatis, how does one write a nested Iterate tag to loop through a two-dimensional array?

I was troubleshooting the following code and was unable to find an answer, so I figured I would document my solution.
The problem was:
<iterate property="twoDimArray" prepend="and (" close=")" conjunction="or">
<iterate property="twoDimArray[]" open="(" close=")" conjunction="and">
$twoDimArray[][].columnName$ = #twoDimArray[][].value#
</iterate>
</iterate>
Resulted in an error:
There is no READABLE property named 'columnName' ...
I found that I needed to reference the second array as a property of the first:
$twoDimArray[].[].columnName$ = #twoDimArray[].[].value#

Resources