h:selectOneMenu doe not work after Myfaces upgradation from 1.1.4 to 1.1.8 - myfaces

Iam using JSF 1 and trying to update Myfaces version from 1.1.4 to 1.1.8
I have something like this in myxhtml page,
<h:selectOneMenu id="orgCountry" value="#{crud.orgAddress.country}
<f:selectItem itemLabel="#{messageResources.dropDownPleaseSelect}" itemValue=""/>
<f:selectItem itemLabel="#{crud.usrbld.countryName}" itemValue="#{crud.usrbld.countryId}"/>
<f:selectItems value="#{getSelectItems('countryDAOCrud')}"/>
<a4j:support id="countryDropDown" event="onchange" ajaxSingle="true" reRender="orgState" oncomplete="updateStateDropdown()"/>
</h:selectOneMenu>
and getselectItems is a normal method,
getselectItems (){
list= gettingfromDB
converting into selectItem type
And country is a normal pojo class with hash and equals method
When Myfaces 1.1.4 is used, everything works fine but when upgraded to Myfaces 1.1.8,
My submit is failing,and that is due to the validation error,which says,
ParametrizableFacesMessage "{0}": Value is not a valid option.
The cause for this error is the matchvalue method in _SelectItemUtil which is,
Object itemValue = item.getValue();
if (value==itemValue || (itemValue.equals(value)))
{
return true;
}
So here the value is the selected value from dropdown and itemValue is one of the items of SelectItem (this is in Iterator Loop), here the value is of my class type and itemValue is string and since they never match validation always fails.
Whereas in Myfaces 1.1.4 the itemValue is converted to class object type and thus the comparison returns success.
I would not be able to upgrade JSF version.
Can anybody please help me in resolving the issue.Thanks in advance.

I had to overwrite the jar method to solve this problem

Related

OpenAPI Generator Kotlin Jackson

I use the openapi generator kotlin module to generate kotlin classes from my openapi.yaml file. The process works fine until I try to deserialize the received JSON in my code to a kotlin class using Jackson.
This is the generated class
data class Request (
#field:JsonProperty("name")
var name: kotlin.String,
)
This is the error I get
java.lang.IllegalArgumentException: Cannot construct instance of `...package.Request` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: UNKNOWN; byte offset: #UNKNOWN]
I noticed that when I remove the "#field:" part in the generated code, then everything works like a charm.
So now my question is can I either remove the #field from the generator or make Jackson deserialize it correctly?
The versions that I use are
jackson: 2.13.1
open-api-generator (gradle plugin): 5.3.0
I had the same error and registering the Kotlin Jackson module fixed it for me: https://github.com/FasterXML/jackson-module-kotlin

Make field insertable but not updatable in Spring Data REST + MongoDB

With Spring Data REST and Spring Data Mongo, I want to make a domain field (field username of domain User in my example) insertable when create but un-updatable when update. In other words an equivalent of JPA #Column(insertable = true, updatable = false).
I try a few approach but not work.
In my github project, domain class and repository are put in /src/main/java/*/*/User.java and UserRepository.java. The test is put in /src/test/java/*/*UserTest.java.
1. Spring Data annotation #ReadOnlyProperty and #Transient
The field is un-insertable when save to DB. See package readonlyproperty and transient_ in the project.
2. Jackson annotation #JsonProperty(access=READ_ONLY)
The field is un-insertable when create via POST request, because the JSON property is ignored when initiate an object. See package jsonpropertyreadonly in the project.
3. #JsonCreator on constructor and #JsonIgnore on setter
If the un-updatable field username is contained in json body of PUT or PATCH request, and username value changes, username get updated, which is unexpected. See package jsoncreator in the project.
4. Do not write a setter
same as 3. See package nosetter in the project.
5. Toggle on/off feature
spring.jackson.deserialization.fail-on-ignored-properties=false
spring.jackson.deserialization.fail-on-unknown-properties=false
spring.jackson.mapper.infer-property-mutators=false
not help
Spring Data REST PUT and PATCH Internal Implementation
PUT: it uses Jackson ObjectMapper.readerFor(Class) to initiate a new object
PATCH: it uses Jackson ObjectMapper.readerForUpdating(objectToUpdate).readValue(json), which use setter to update the objectToUpdate. Seems readerForUpdating doesn't see the #JsonIgnore on setter.
The only solution I know is implementing the setter in below way
void setUsername(String usernameToSet) {
if (null == this.username)
this.username = usernameToSet;
}
And disable PUT method, only use PATCH to update. See package setterchecknull.
Is there a better way? Thank you very much!!

Get pluginId stored in the IPreferenceNode in Eclipse

I am developing a plugin, in my plugin I want to get another plugin ID. I use the following code:
PreferenceManager pm = PlatformUI.getWorkbench( ).getPreferenceManager();
List<IPreferenceNode> list = pm.getElements(PreferenceManager.PRE_ORDER);
String pluginid;
// restoreDefValues("org.eclipse.ant.ui");
for(IPreferenceNode node : list){
the code to find the node related to the plugin;
}
When I debug the program, I can clearly see that in variable node(IPreferenceNode), it has the value of the pluginId. However, I check the document of IPreferenceNode, it seems that the neither IPreferenceNode nor the class PreferenceNode, provide a method to return the value of pluginId. I tried node.toString() as well, couldn't get the pluginId. So what should I do? Is there any other ways to get a plugin ID from another plugin?
Preference nodes created using the org.eclipse.ui.preferencePages extension point will actually be instances of org.eclipse.ui.internal.dialogs.WorkbenchPreferenceNode. The super class of this (WorkbenchPreferenceExtensionNode) contains the plugin id.
These classes are internal so you should not try to use them directly. However they implement org.eclipse.ui.IPluginContribution which can be used and has a getPluginId() method.
So something like:
if (node instanceof IPluginContribution) {
pluginId = ((IPluginContribution)node).getPluginId();
}
should work.

indexOf for strings not working after struts jquery plugin 3.7.1 upgrade

I upgraded struts jquery plugin to 3.7.1 and jquery-ui.js to 1.10.4.
With my previous struts jquery plugin 3.1.1 and jquery-ui.js 1.8.15, indexOf for the strings is working. Dont know where it hit after upgrade. I get the following error.
SCRIPT5007: Unable to get value of the property 'indexOf': object is null or undefined
My code is as below.
var innerSpanId = $(this).attr('id');
var value = innerSpanId.indexOf('accountcheckbox');
Do give in your suggestions?
I was trying to get the index of strings without an object.
In upgraded jquery use the string object.
var innerSpanId = new String($(this).attr('id'));
var value = innerSpanId.indexOf('accountcheckbox');
Works Perfect!!!

Struts 2 setter unknown field parameters

My struts 2 (2.3.1) application at debug mode for url http://localhost/app/check.action?13239 raises such kind of exceptions
2011-12-15 14:45:06,455 DEBUG [CommonsLogger.java:68] : Setting static parameters {}
2011-12-15 14:45:06,456 DEBUG [CommonsLogger.java:68] : Setting params NONE
2011-12-15 14:45:06,456 DEBUG [CommonsLogger.java:68] : Setting params 13239 => [ ]
2011-12-15 14:45:06,461 WARN [CommonsLogger.java:60] : Error setting expression '13239' with value '[Ljava.lang.String;#33b4450e'
ognl.InappropriateExpressionException: Inappropriate OGNL expression: 13239
at ognl.SimpleNode.setValueBody(SimpleNode.java:312)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
I was expecting silently ignoring them according to documentation. What is the correct way to fix this problem?
By the way it seems that struts looking for a setter field for the value 13239 however I guess that it is not suitable for a property which is started by a number.
That is more or less a issue of your personal taste.Sometime we wants to know any time a parameter is submitted that doesn't have a matching getter/setter on the action and its a common use case in development our application and we forget a getter/setter on an action, we want to know about any possible error case.
One possible way to is setting the logging level differently from dev to production.There was a long discussion about this on Struts2 mailing list here is the link for same
OgnlValueStack Error setting expression warnings after upgrade from struts 2 to struts 2.1.7