Setting field read-only depending on errors - xpages

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()

Related

DAC Field UI warning indicator behaving like error

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.

BluePrism Spy element uniquely

I am spying one button from one browser based application. But I am getting the error saying more than one item found.
I am able to spy it only under the Accessibility Mode.
Although,I can see in my page that there is only one element in my page.
How to refer my element uniquely under Accessibility Mode as there is no exact path to specify.
If you are not able to see the elements, but Blue Prism is saying that there is more than one element found, then you may have unchecked these two attributes:
Visible
Screen Visible
Try setting them as "True", and please check if that will help with your problem.
Different approach would be to use one of these two:
Match Index
Ordinal
In a nutshell, they tell Application modeller about which item should be used, if there are multiple similar object visible.
I think it happens when you are having two fields having same properties like in a login page, username & password have same properties when you spy these elements using Blue Prism it shows the error.So, to get rid of that error, check the box ordinal in the application modeller popup(which opens after clicking ctrl+left click) after you've spied the element.I hope you got it.
Whenever we spy elements it is recommended to uncheck few attributes like parent url, input identifier, title etc.
"if there is an error stating that more than one matching window found" then at this point we have to uncheck "windows text" and check the ordinal attribute.
Please try below in Application module
Uncheck the checkbox with empty values
Uncheck the ParentURL.
You just need to check the Match Index and Ordinal property of the spied element. Ordinal will always gives you the unique element on the screen.
This is even mentioned in Blue Prism's Training module.
For Browser/Web-based application, Ordinal Attribute cant not be found.
To Spy the exact element, you can also use "Application Navigator" or UI Automation Navigator.

Refresh edit box after information change

I have edit box which has validation- it is required field and it has range of values validation as well. The validation works ok, but the problem is that error message does not dissapear when I replace the values in edit box with valid ones. I tried to add full update on onchange event but this is not a option for me since this changes other fields in my xpage as well. The partial update on the field does not work. Any advice how to refresh the field so that error message dissapears?
Create a wrapper panel or div around BOTH the field and the error message control and set it's ID to the one that should be partially refreshed. I assume you use
XSP.partialRefreshGet("#{id:idOfYourField}")
in the onblur client event!? So just change the ID name here.

"Visible" property on XPages edit boxes based on checkbox selection(s)

I am new to XPages, and I have a Check Box Group ('checkBoxGroup1') as one of my design elements that contains three choices ("CBChoice1", "CBChoice1", "CBChoice1"). Underneath that Check Box Group, I have three edit box fields which correspond to the three checkbox choices. Each time one of the checkbox choices is chosen, I want the corresponding edit box to become visible.
Whenever one of the checkboxes is chosen, I have it partially refreshing the panel that the edit boxes are in, but I cannot figure out the code in each of the edit box's visible property. I started with
getComponent('checkBoxGroup1').getValue() == "CBChoice1"
which kind of works, but isn't the answer. I also tried
var valueArray = getComponent('checkBoxGroup1').getSelectedValues();
valueArray[0] == "CBChoice1";
which seems more on target, but I was getting the following browser error:
Error 500 HTTP Web Server: Command Not Handled Exception
I notice that in the computed code for the visibility property, it is SSJS. I feel like I am close, but have been banging my head for too long. Any help would be greatly appreciated.
A better method might be to bind the checkbox group to either a document data source or a scope variable.
Then, your visible property might look something like:
#Contains(myDoc.getItemValueArray("checkBoxFieldName"),"CBChoice1");
or
#Contains(viewScope.get("checkBoxScopeVar"),"CBChoice1");

How to set the order of validation messages?

We're using the "Error Messages" XPages (native) control to show the validation errors to user. It works. The validation is done by setting the field as required and entering the field error message. Nothing special.
Now the requirement is to set the error messages in to the same order as they appear in the form. Is this possible?
I guess I could create a custom validator (Java) and doing all the form validations there in certain order (just tested the Validation interface... but not really used id, yet).
There's the old (unresolved) argument: should the errors appear next to the control that failed the validation, on top of the form or next to the button you pressed for submission. I tend to put them next to the failed control and have ONE message next to the button reading: "Sorry I couldn't process the input, help me and fix the fields that have error messages next to them". Then sequence isn't an issue any more. If you want to be 100% sure you could instead of the summary control use the individual controls next to each other.
What anyway would be a nice exercise: let the error message control alter the css of the failed control, so it becomes clearer what to look out for.
The Validations are fired one by one in order they are in the component tree. Depending on how you are wanting them to display you could move the components around and then style them with css. Or if you are really just wanting to move the order of the summary statements around in the Messages Box, I would just use some JS to move them around I believe they just render as a UL. Only having one Validator won't really work as the same validator will get fired for every component in the order of the component tree.

Resources