What is global error (in spring validation)? - spring

I'm checking spring-validation Errors(BindingResult) interface. It mentions global errors in contrast with field erros. What are global errors?

FieldError (javadoc)
registered via rejectValue (javadoc)
attached to a field
Example:
errors.rejectValue("name", "name.empty", "cannot be empty")`
ObjectError (global error) (javadoc)
registered via reject (javadoc)
not attached to a specific field (either multifield or not field related)
Examples:
errors.reject("password.mismatch", "Password doesn't match confirm password")
errors.reject("optimistic.out-out-date", "This page has been saved in the meantime. Reload it and start editing it again")

Related

Change error system message in oracle apex

I have a form page and all field is required when press save the below message appear
How i can change this message to custom message "please fill all required fields " , and how i can clear error when enter value (when value change to not null).
I can't see images at the moment.
However, one option might be to create your own validation which returns error text. Something like
if :P1_NAME is null then
return ('Name must be entered');
end if;
Messages are automatically cleared once you submit the page and there are no errors left.
I am not sure if you can change system messages but you can add custom error messages with javascript if a change happens in any item.
Add a change event to the item that runs javascript and use the following code:
var item = apex.item('P1_ITEM').getValue();
if(item == null) {
//First clear the errors
apex.message.clearErrors();
// Now show new errors
apex.message.showErrors([
{
type: "error",
location: [ "page", "inline" ],
pageItem: "P1_ITEM",
message: "Name is required!",
unsafe: false
},
{
type: "error",
location: "page",
message: "Page error has occurred!",
unsafe: false
}
]);
}
However, this will not stop the user from submitting, it only allows you to better display the messages, so you must add the corresponding validations after submit.
If you want to remove the system error message from the required items, you can disable the option of Value Required on item and add a custom validation as they told you in the other response.
If you want to explore all the apex.message options better, I recommend this documentation:
https://docs.oracle.com/database/apex-5.1/AEAPI/apex-message-namespace.htm#AEAPI-GUID-D15040D1-6B1A-4267-8DF7-B645ED1FDA46
More documentation for apex.item:
https://docs.oracle.com/cd/E71588_01/AEAPI/apex-item.htm#AEAPI29448
There are some ways for how to do such things.
Firstly you have the custom Validations you can make, these are awesome and you should really try to use them if possible.
Then there is also the Error message on the saving procedure, but this just throws a custom message on procedure fail so I never use it.
What you appear to be seeing there is that you got an error message and didnt change the fields associated with the error.
If the save procedure is custom, you can also put in an EXCEPTION block before the END, and catch errors there and throw out a custom error with a custom error message.
Another thing I really like is to actually rename some common errors so I dont have to catch them all individually. Say clients may often times try to save identical data, thus breaking the PK. Oracle will throw an error, but the message is good for the developer, but less understandable for the client whom I always assume is a 3 year old kid who can barely read and will cry over everything. So I make an error handling function, add it to apex, and so when the error occurs, it throws a nice message informing the client that they have tried to add some data that already exists.
So, an error handling function associated with APEX, to rename some normal errors.
Good luck

Undeclared property when creating a record via Web API In Dynamics CRM Online

I am trying to create an entity in Dynamics CRM online with a custom lookup field. Even after providing the SchemaName(sg_DepartmentalProjectId) as mentioned here 'An undeclared property' when trying to create record via Web API I am still getting the same error.
An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'sg_DepartmentalProjectId' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.
Below is my JSON Post
{
"sg_invoicenumber": "SIAIR402742-416805",
"sg_accountnumber": "5400",
"sg_description": "xxxx",
"sg_fy": "20",
"sg_name": "Operational Journal: yyy - 09/20/2019",
"sg_departmentid": "CC10530",
"sg_postingdate": "2019-09-20",
"sg_invoicedate": "2019-09-20",
"sg_checkdate": "2019-09-20",
"sg_paidfulldate": "2019-09-24",
"sg_amount": 5597.4,
"sg_effectivedate": "2019-09-20",
"sg_DepartmentalProjectId#odata.bind":"/sg_departmentalmatters(e9c31cec-deff-e411-80c5-0050569732ae)"
}
Please Download Odata Metadata from the Developer resources & verify the exact casing. Jason Lattimer also confirmed that the bug while investigating the CRM REST builder issue:
I've come to figure out the metadata is in fact not the source of truth - it's the CSDL
I know it's super annoying when this is working different & getting solved by different solutions. Make sure you verify in all these places for the custom lookup attribute.
Microsoft reference: CSDL $metadata document
I had the same problem, but in my case using the schema name didn’t work. I believe it’s because my field is setup as a navigation property to either of two different entities. I found the correct name by pulling the metadata for the entity from the API and looking at the navigation properties. There were two navigation properties defined for this field, one for each target entity, so I had to use the name of the correct one in my payload.
<NavigationProperty
Name="parentcustomerid_account"
Type="mscrm.account"
Nullable="false"
Partner="contact_customer_accounts">
<ReferentialConstraint
Property="_parentcustomerid_value"
ReferencedProperty="accountid" />
</NavigationProperty>
The correct value was parentcustomerid_account above.
I had same issue
JSON:
{
"activityid": "cbf73794-9e42-ec11-8c62-00224815945f",
"subject": "Test 22",
"new_AppointmentTypeId#odata.bind": "new_tasktypes(a97ec3cf-3e1a-ea11-a811-000d3a799417)"
}
Error I was getting:
An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'new_AppointmentTypeId' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.
Resolution:
Use Metadata Browser https://learn.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/browse-your-metadata?view=op-9-1
Find ReferencingEntityNavigationProperty from Metadata Browser for fields you need it.
Working JSON:
{
"activityid": "cbf73794-9e42-ec11-8c62-00224815945f",
"subject": "Test 22",
"new_AppointmentTypeId_Appointment#odata.bind": "new_tasktypes(a97ec3cf-3e1a-ea11-a811-000d3a799417)"
}

How to use kubebuilder's client.List method?

I'm working on a custom controller for a custom resource using kubebuilder (version 1.0.8). I have a scenario where I need to get a list of all the instances of my custom resource so I can sync up with an external database.
All the examples I've seen for kubernetes controllers use either client-go or just call the api server directly over http. However, kubebuilder has also given me this client.Client object to get and list resources. So I'm trying to use that.
After creating a client instance by using the passed in Manager instance (i.e. do mgr.GetClient()), I then tried to write some code to get the list of all the Environment resources I created.
func syncClusterWithDatabase(c client.Client, db *dynamodb.DynamoDB) {
// Sync environments
// Step 1 - read all the environments the cluster knows about
clusterEnvironments := &cdsv1alpha1.EnvironmentList{}
c.List(context.Background(), /* what do I put here? */, clusterEnvironments)
}
The example in the documentation for the List method shows:
c.List(context.Background, &result);
which doesn't even compile.
I saw a few method in the client package to limit the search to particular labels, or for a specific field with a specific value, but nothing to limit the result to a specific resource kind.
Is there a way to do this via the Client object? Should I do something else entirely?
So figured it out - the answer is to pass nil for the second parameter. The type of the output pointer determines which sort of resource it actually retrieves.
According to the latest documentation, the List method is defined as follows,
List(ctx context.Context, list ObjectList, opts ...ListOption) error
If the List method you are calling has the same definition as above, your code should compile. As it has variadic options to set the namespace and field match, the mandatory arguments are Context and objectList.
Ref: KubeBuilder Book

Grails define custom error message for command object

I am writing a Grails (2.3.3 currently) application and have created a validateable command object similar to the following:
#Validateable
class MyCustomCommand {
String name
static constraints = {
name blank: false
}
}
In my i18n/messages.properties file I defined the following properties to override the default error messages.
MyCustomCommand.name.blank=Name must be provided.
MyCustomCommand.name.null=Name must be provided.
Which per the Grails documentation should be of the format [Class Name].[Property Name].[Constraint Code] as I have done. When I run my application if I leave the value blank I still get the default message for a null property.
I also tried following the example of the default messages and defining them a follows, but still get the default message.
MyCustomCommand.name.blank.message=Name must be provided.
MyCustomCommand.name.null.message=Name must be provided.
I am assuming that I am missing something simple here, but have yet to stumble upon what. Any suggestions on what I am doing incorrectly?
It is simple indeed. Message should look like:
myCustomCommand.name.blank=Name must be provided.
myCustomCommand.name.nullable=Name must be provided.
//className.propertyName.blank (camelCase with first letter of class name lower)
So, as I anticipated it was something simple. I was using the defaults as an example which used null where as what I really needed was nullable. Which does make sense as that matches the constraint name.
Therefore the correct version is:
myCustomCommand.name.blank=Name must be provided.
myCustomCommand.name.nullable=Name must be provided.

The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted

I'm trying to send a message to a queue using a Message object and am getting the error
The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted.
Here is the code.
Order ord = new Order(new Guid(), "Smith & Smith");
Message orderMessage = new Message(ord);
orderMessage.UseEncryption = true;
orderMessage.EncryptionAlgorithm = EncryptionAlgorithm.Rc2;
orderMessage.Recoverable = true;
orderMessage.Priority = MessagePriority.VeryHigh;
orderMessage.TimeToBeReceived = TimeSpan.FromHours(1);
orderMessage.UseJournalQueue = true;
orderMessage.Body = "Test Encryption";
queue.Send(orderMessage, "Encrypted Order");
Any help with this is appreciated.
Tom
Did you ever solve this? I came across this problem myself and found out I needed to use (just like the error says) a different format name.
The strange thing was that if I set UseAuthentication property using the MQ certificate, then it worked. But if I also wanted to set UseEncryption, then it did not work.
You do not specify your queue/server setup/formats, but I suspect you're trying to send from one machine to another machine's public queue within the same domain, using DIRECT formatname? As the MQ Manager will use the domain AD to lookup the certificate and queue details, it raises an exception as the format name is invalid (not the same as specified in the AD). So instead of using the direct format, use the queue ID to define the formatname. I switched this:
"FormatName:Direct=TCP:111.222.1.22\your_public_queue"
with this:
"FormatName:PUBLIC=7EB2A53C-7593-462C-A568-5A0EFA26D91D"
Now it worked. You can find your queue ID by right-clicking your queue on the receiver machine and then go to Properties->General and see the value specified in field "ID".
I have found that getting the FormatName correct whether public or private in nature will save hours of work. It's incredibly important to understand the setup of each (Public requiring AD and private does not when access remotely). This is a great summary of FormatName.
https://blogs.msdn.microsoft.com/johnbreakwell/2009/02/26/difference-between-path-name-and-format-name-when-accessing-msmq-queues/
One note on this issue, if your queue format name starts this way: "FormatName:Direct=" then you will receive the error "The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted" if you try to access the queue's QueueName property. Use the queue's FormatName property instead.

Resources