When editing an Input Field and trying to add a Validator I get this error:
The validator field I'm talking about
Cannot convert class java.util.LinkedHashSet to class java.lang.String
I understand the error but not sure how to fix it.
Did anyone run into this problem and how did you fix it?
My magnolia version: 5.4.6
Thanks!
If I guess the context correctly, this validation field is from the Form module; more precisely it is a Twin-column field, configured in the formEdit dialog.
The "Cannot convert class" error usually occurs when the Vaadin field is incompatible with the Magnolia/JCR property it's trying to save to.
Use the JCR Browser app to see (and delete) if there is any pre-saved String value for the validation property of this component. Well-formed "multi-values" are displayed within square brackets, e.g. [email].
I could not reproduce this error on the Magnolia Demo—currently running 5.6.3, so if the above doesn't solve it, this could come from the dialog/field configuration, if you use a custom one. As a reference, the formEdit dialog is configured at:
/modules/form/dialogs/formEdit/form/tabs/tabMain/fields/validation.
Related
I have created a Java client to interact with a SOAP webservice using Axis2 (1.7.6) as code generator. The problem is with some inputs the client is throwing an exception with the message:
org.apache.axis2.AxisFault: Invalid white space character (0x4) in text to output (in xml 1.1, could output as a character entity)
It seems the serialiser is hitting some chars considered invalid to XML spec. I have seen that problem around but no definitive answer or the fix. I'm not using Spring or any other dependency injection framework, it's a standalone application, so I need to configure the inners of Axis2 by hand.
Any ideas on how to fix/configure the client properly?
After some research I found this behaviour is due to one default setting of the lib Woodstox (Axis2 dependency), that uses the class com.ctc.wstx.api.InvalidCharHandler.FailingHandler as default implementation of the interface com.ctc.wstx.api.InvalidCharHandler, used inside com.ctc.wstx.sw.XmlWriter and invoked in the serialisation process. This means: when the component hits characters considered invalid to XML, it’ll throw an error.
Woodstox provides another implementation of the interface com.ctc.wstx.api.InvalidCharHandler, the one called com.ctc.wstx.api.InvalidCharHandler.ReplacingHandler that instead of throwing errors will replace those chars for something else. But how to do that?
The class com.ctc.wstx.stax.WstxOutputFactory inside Woodstox contains several configurations, one of them being the invalid char handler. Though, it's not configurable by some magic system wide property, instead, by the method com.ctc.wstx.stax.WstxOutputFactory#setProperty, that takes as arguments one string and one object.
So first, you'll have to extend that factory and set the property com.ctc.wstx.outputInvalidCharHandler with an instance of com.ctc.wstx.api.InvalidCharHandler.ReplacingHandler that takes as argument the char you want to replace the invalid ones with. Like this:
package my.package;
import com.ctc.wstx.stax.WstxOutputFactory;
public class MyWstxOutputFatory extends WstxOutputFactory {
public MyWstxOutputFatory() {
setProperty(
com.ctc.wstx.api.WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER,
new com.ctc.wstx.api.InvalidCharHandler.ReplacingHandler(' '));
}
}
The second, trickiest and undocumented step is how to register your implementation as the factory Woodstox'll use. You'll have to create a file named META-INF/services/javax.xml.stream.XMLOutputFactory simply containing the name of your factory, in this case, the string:
my.package.MyWstxOutputFatory
Place this file in such a way it's included in your project's resulting jar. In my case I placed like: src/main/resources/META-INF/services/javax.xml.stream.XMLOutputFactory.
And you're done!
I have the following class:
class Foo
{
#NotEmpty
private String member1;
#NotEmpty
private String member2;
private String member3; //this one is optional, so has no rules
}
I have a library to which I add all the property names and corresponding UI fields, each time the UI's onChange event occurs, I call validateValue() on the given field name for that field, to validate it and show error/success message.
The problem is, in this case where I have no rules for member3, if I try to validate it by doing this:
String value = event.getValue(); //whatever the new value is now
validator.validateValue(Foo.class, "member3", value);
On the 2nd line, I get the following exception:
Caused by: java.lang.IllegalArgumentException: member3 is not a valid property of
com.xxx.Foo
Both member1 and member2 within the same class, are validated correctly.
Is there anything I can do to avoid getting this exception on the fields that don't have any rules set on them? If not, is there a way (without reflection or specifying it manually for each field) to check if a rule has no rules set on it, so i can avoid calling validateValue on it?
Which version of Hibernate Validator are you using? I checked with the latest version (5.1.0.Final) and there it works. If you can I recommend you upgrade.
You can also create an issue in the Validator issue tracker, reporting your problem and in particular which Validator version you are using.
Last but not least, to answer your question about alternatives. You could use the Bean Validation metadata API to find the constrained properties:
validator.getConstraintsForClass(Foo.class).getConstrainedProperties()
This will allow you to process only the properties which are acually constrained.
I'm a newbie in Liferay and I'm creating a hook to authenticate using a expando column instead of an email address.
My authentication class works fine, but one problem still remains:
After a successful authentication, I must redirect the page to the user's public or private page (any of theese is enough for me)
I followed the common of instructions for this on any forum on Internet:
Create a class that extends com.liferay.portal.kernel.events.Action and do the logic there. In my case, my class is named CustomPostLoginAction
Modify portal.properties adding the entries
login.events.post=com.liferay.sample.hook.action.CustomPostLoginAction
auth.forward.by.last.path=true
default.landing.page.path=/web/guest/home
Redeploy and "voilá"
When I reboot my web server, everything is fine, but when I run my hook using any browser, once I get successfully authenticated, it stills showing me the default login error messages. When I check my console, I found that my action class is never called and no special action is executed after my authentication class. So I have the following questions:
Where can I found an example to class to be used as a value for the property "auth.pipeline.post" if needed?
On the method authenticateByEmailAddress on my authentication class, the last argument is a java.util.Map containing parameters like "doActionAfterLogin", "redirect", "structsAction", etc. Do I get something if I assign values to those keys on that map? If yes, where can I found an example of valid values to assign to each one of them?
Do I have to change something in my custom login page? (it works, but still I have to ask this)
Is it necessary to work with the class DefaultLandingPageAction? If yes, how can I do it? Because I have only the portal's bytecodes (.class)
And most important: What am I doing wrong?
For the record:
I'm using Liferay 6.1 bundle with Tomcat 7 and SDK included with Liferay's default database.
If any of you need to watch any of my source code and/or properties files, just let me know and I will publish them.
Thanks in advance to all of you.
I can't add a comment to your original post so I'm gonna have to post an answer to ask you for some additional information (will update my answer accordingly).
Did you modify portal.properties directly or did you create a new portal.properties inside your hook?
Once you extended com.liferay.portal.kernel.events.Action, did you override the run method?
I am getting an error message in my JSF pages... Conversion error setting value 'delovenier' for 'null converter', where delovenier is the name of the chosen project.
I'm not sure why this is happening. Could someone please assist me.
This is my JSF code...
<h:selectOneListbox id="proj" value ="#{studentEController.gekozenProject}">
<f:selectItems value="#{studentEController.projecten}"></f:selectItems>
</h:selectOneListbox>
And this is my code in the managedBean StudentEController.
private List<ProjectE> projecten;
private ProjectE gekozenProject;
As you can see, they have the same type of ProjectE.
Data transferred between the server and the client will be in string form.
The Expression Language can coerce a set of standard types (ints, etc.), but for complex types you are going to have to add a Converter to your component. Your converter will serialize ProjectE types to strings at render time and deserialize them to new ProjectE instances when forms are submitted.
You can create converters for specific types or add them explicitly to components.
See Creating a Custom Converter in the Java EE 6 tutorial and the <f:converter> tag.
I'm getting the following error in ours logs:
Error looking up property "foo" in
object type "foo.bar". Cause: null
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor363.invoke(Unknown
Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1773)
I cannot for the life of me recreate it, I was wondering if anyone has any experience with this kind of problem with JSP/Java Bean. What I wanted to know was, will this prevent the user from getting the web page to show up?
I know this isn't a whole lot of information, but any advice could help.
Something on some page is trying to "navigate" into a bean instance (a Java object, that is), and it's trying to get to a property that isn't there on the bean in question.
<span id='name'>${fn:escapeXml(someBean.user.fullName)}</span>
If the bean "someBean" has no "user" property, of if the user object has no "fullName" property, you get an exception like that.
From what you're giving here, the only suggestion I have is to make sure that you have indeed a property called "foo" and to not have a period in "foo.bar". You cannot name your variables/objects using a period in the name. JSP will automatically go and look for a property called "bar" in "foo". Call it instead "fooBar".
Java is calling the getter method on the bean providing the property which is in turn throwing an exception. If you can see the target exception - that is the target of InvocationTargetException you will know what is causing this to fail.