Validation feedback from a Java action

1
Hi, Im trying to create a Java action that can do a validation feedback, given a Entity and AttributeName. I have tried to use the DataValidationInfo class and .addErrorField(MemberName, Message), but it won't be shown on screen. I think I'm missing something ;-) // .... DataValidationInfo dvi = new DataValidationInfo(Entity.getId().toLong()); dvi.addErrorField(this.AttributeName, "Oops!"); // .... How do I do this? So just a custom version of the existing “show Validation message” action.  
asked
2 answers
0

You need to look at addDataValidationFeedback in the Core API.

https://apidocs.rnd.mendix.com/8/runtime/com/mendix/core/actionmanagement/CoreAction.html#addDatavalidationFeedback(com.mendix.systemwideinterfaces.core.IMendixIdentifier,java.util.Map)

Mina covered this as part of his talk on Creating and Debugging Java actions at this years Mendix World. Here's a link to the session, it’s worth a watch.

https://events.mendixworld.com/widget/mendix/world21/catalog/session/1621626724715001fi3l

Hope this helps.

answered
0

Great video by Mina, I noticed the link doesn’t work so here is an alterative: https://www.mendix.com/videos/creating-and-debugging-java-action/ 

For reference when video link might become broken: 
y

	@java.lang.Override
	public java.lang.Void executeAction() throws Exception
	{
		// BEGIN USER CODE
		DataValidationInfo dataValidationInfo = new DataValidationInfo(ObjectToValidate.getId().toLong());
		
		if(ObjectToValidate.hasMember(AttributeName)) {
			
			dataValidationInfo.addErrorField(AttributeName, ValidationMessage);
			this.addDataValidationFeedback(dataValidationInfo);
			
		}
		
		return null;
		// END USER CODE
	}

ou can tldw:

 

answered