I am raising a warning message on a field in its FieldUpdating event handler, but it is displaying and behaving like an error instead of a warning. In other words, red instead of yellow icon, and turns the field value red. Any ideas why it might be behaving like this? Below is the exception being thrown. I have also tried sender.RaiseExceptionHandling, and putting this in the FieldVerifying instead, but it still shows as error.
throw new PXSetPropertyException(string.Format("Instead of using this description, consider using the existing description: '{0}'",
closestFound.Key.Description, PXErrorLevel.Warning));
I was able to get it to behave like I want by using PXUIFieldAttribute.SetWarning instead of raising an error. Maybe PXErrorLevel.Warning doesn't actually behave like a warning, not sure.
Related
What is the best way to raise validation exception in Grid Cell, Grid Row, Form View and on Saving?
For field level, I am putting fieldVerifying and raise PropertySetException it show exception on field with red mark.
On saving handle RowPersisting event, it raise exception if any validation fail it will show alert message, but not showing on cell or row or field.
Is it good way to handle validation exception?
May you suggest any batter way to handle validation exception?
Should we put validation exception in RowPersisting(to avoid wrong data saving) as well as FieldVerifying?
You can use cache.RaiseExceptionHandling instead of throwing an exception in RowPersisting event to highlight the field with the error sign.
You can also control where the error sign appears by specifying Error Level, like that:
sender.RaiseExceptionHandling<DAC.field>(e.Row, sender.GetValueExt<DAC.field>(e.Row), new PXSetPropertyException(message, PXErrorLevel.Error));
PXErrorLevel.Error will set the error sign on the field, PXErrorLevel.RowError will mark the entire row in the grid with the error sign.
Depending on the UI requirement you can either keep the verification on FieldVerifying, or you can do both FieldVerifying and RowPersisting
I am getting this warning org.primefaces.PrimeFaces$Ajax.update PrimeFaces.current().ajax().update() called but component can't be resolved!Expression will just be added to the renderIds. Sometimes when using PrimeFaces.current().ajax().update I get the above warning, searching I implemented this solution https://forum.primefaces.org/viewtopic.php?t=58678
public static UIComponent findComponentById(String componentId) {
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot root = context.getViewRoot();
return root.findComponent(componentId);
}
So to avoid getting the warning I do the following:
if (FacesUtils.findComponentById("pnlEstado") != null) {
PrimeFaces.current().ajax().update("pnlEstado");
}
And it works, it does no longer throw the warning because component is always "findable" for updating.
The problem here is that my partner said he isn't sure if this is the best way to handle the warning because he thinks it will take alot of time when this is in production for it to execute, he said like this goes to client then comebacks to server then again to client, how this works he asked, and I didn't really know how to explain but the thing is I think this is the best way to handle it, want to know your opinion about it.
I also tried with binding component and checking if it is rendered but it is always true that it is rendered so it always updates and throws warning.
So I removed bindings and used this way. Also this only happens because I have 2 menus, when 1 is open the other one is not displayed, so I think thats why the update throws warning sometimes, but the solution I implemented solves it, anyways im open to your opinions.
Also this is the way he said he prefers me to solve it, im gonna try it https://forum.primefaces.org/viewtopic.php?t=32040
But I think its better with the one I want to use
The warning happens because the component for the given IDs can't be resolved in the current ViewRoot.
For the same reason, your FacesUtils.findComponentById returns null.
In PrimeFaces we just added this warning to inform the user, that the component to be updated, is likely not there and/or wont be updated. This can of course lead to a unexpected behavior for the developer.
So your FacesUtils.findComponentById is just a hack which leads to worse performance, as 'viewRoot.findComponent' will be called twice when the component is available.
The only real solution is to only call PrimeFaces.current().ajax().update() if you know that the component is rendered. Your view bean/controller should know the current state.
Otherwise just ignore the warning.
I have few components- combo boxes, edit boxes and error messages.
What I'm trying to do is to make combo box read only if the error message (that is attached to the edit box) contains something.
I'm trying to use this in the "read-only" computed field:
getComponent("message3").value == ""
Apparently i'm doing something wrong and it throws error when I load the xpage. Any advice how to achieve the functionality I need?
You can use the following to check for error messages:
facesContext.getMessages().hasNext()
Most of my code is error handled with try/catch and OpenLog (modified to handle SSJS exceptions). Unfortunately, exception in SSJS gives hard to read stack trace.
So I need to pass more info - at least event/method where is the error handler. I can simply put "method XY" argument to every OpenLog.logError call, but this makes every handler unique and prone to errors (programmers love copypasta). It would be nice to have LSI_Info equivalent, what makes error handlers constant (so you can define them as template in Eclipse).
Is there any call, which returns "where I am" info of method/event for SSJS code (including libraries)?
Have a look at the code in the Message class of my debug toolbar (found here on GitHub). I contains a way to 'pretty print' errors and also captures a com.ibm.jscript.InterpretException. I use that to send a formatted error message to an OpenLog event document. It (sort of) mimics the information you get in the default XPage error page.
To see what the formatted error looks like go to my toolbar's demo page and hit the Test 1 or Test 2 button. That will throw a SSJS error that is captured by a custom error form. That form writes a message to the toolbar which is configured to also store error messages in a separate OpenLog database.
(toolbar download can be found here on OpenNTF)
I'm facing some validation/message problem with ICEFaces. I have a page with some input fields, validators, and a message bar with an <ice:messages /> tag. If the user fails to properly complete an input field a validation error occurs, and an error message shown in the message bar. So far, so good.
But if the user types an incorrect value for the second time too, no new error message shown.
I would like to know how to change this behaviour. I need an error message every time the user fails to set a proper value, not just for the first time.
How can I do that?
Thanks in advance.
Are you sure you're not receiving an exception after printing the error message?