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.
Related
One of my clients has a replica copy of a database on two different Domino Servers. On one of the servers if the user clicks on any white space on a view or form they get the following error:
While the database on the test server does not throw this error. My server likewise does not throw this error either. as far as I can determine they are both running the same release of Domino.
I have search my code but can't find any reason for this error.
Any pointers where to look.
Check for eventHandlers on your page, looking for one associated to a component that does not have an ID. I think what happens is that if you have an eventHandler on a button, comboBox etc that does not have an ID, it gets associated to whatever contains the button, comboBox etc. So it triggers when you click in that area.
If you find one, add an ID and it will resolve the click problem.
I'm not 100% sure what the refreshId issue is, maybe the eventHandler in question is set refreshMode="partial" but not refreshId set, so it's trying to refresh the component containing the eventHandler, which is the one that doesn't have an ID. I could understand how that would cause a problem.
I have a page where I wanted to use the "enableModifiedFlag" property, to let users know that their edit was not saved if they want to leave a page before saving.
I also have a search box in that page, and when I set the field to the static value "true", the message was popping because the search box was considered part of the page, and the field was modified. This all makes sense.
Since the "enableModifiedFlag" property can be computed, I decieded to set it to true only if the document was in edit mode, as the search box is not available at that time. The behaviour I got was that the message was not appearing anymore. I then tested with returning true as the value of the property, and it didn't change anything: the message was just gone. I then used the static values and set it to true, and the message was then appearing.
My conclusion is that there is a bug that prevents any computed value to be considered for that property.
So I had to find a workaround to prevent the message from popping up when users used the serach box. Here is the solution I came up with.
On the client side, we have access to the XSP object. One of its method is XSP._setDirty(). you can either set it to true or false, and it will affect if the page diplays the popup message or not. So in my search button, I added this code on the onclick event, on the client side:
XSP._setDirty(false,""); //so we don't get the "do you want to leave this page" message
showStandBy(); //show standby in case search is long or slow
return true;
That way, I tell my page not to show the message and the popup is not displayed.
It's still a shame you can't use the computed value for that property, but at least we have a workaround. Hope this will be useful to somebody!!!
GOT SOMETHING WORKING I THINK
This is what I have now, that controls teh flag:
<xp:this.enableModifiedFlag><![CDATA[${javascript:context.getUrlParameter("action")=="editDocument";}]]></xp:this.enableModifiedFlag>
I would rather use the document1.isEditable() function, but I wasn't successful with it so far, neither computed dynamically nor on page load.
At leaset I have something that seems to be working. Time to submit that code to the end users!
I have set up the jQuery-Validation-Engine addon (https://github.com/posabsolute/jQuery-Validation-Engine) and it works great on the submit button.
However, since i invoked a tab-based interface, it doesn't really bring the user back to the proper tab with the error fields.
As a work around, i've decided its better to validate each tab when leaving to the next one (as it is a step-wise tab) so that the button click at the end will only 'really' need to correct any errors on the currently displayed tab.
I'm using a simple anchor to call some div swaps (using negative margins for content off-page).
I'd like to invoke the validation method to this as well.
Documentation says it can only be attached to a form element.
Any ideas?
Update- i ditched the tab idea and am now using one big form so this no longer really applies.
No support led to going after a different approach. No longer needed.
Some of my recent posts have to do with the fact that I am doing all of my validation in my Submit button.
The reason I am doing this is that I have a button that sets some read only edit boxes. Well you can configure a validation for a read only edit box but it does not execute at run time.
Since I could not figure this out and wanted to have a consistent look for validation I used my own validation on my Submit button.
Is there a way to validate read only fields?
One nice thing about putting all of the code in the Submit button is that all of the validation code is all in the same place but I can see where it also can cause portability issues when using custom controls.
Also another question is how to fire off validation if my Submit button is not marked as a Submit button.
As Dec says, the ReadOnly flag causes the content of the field to be rendered without the <input> tag. This makes validation impossible on the client side and since there is no data being submitted back to the JVM, validation coded on the field is ignored on the submit.
However, the data source QuerySaveDocument is triggered. Put your validation in there and/or put it in the fields that are rendered (readOnly=false) and be sure to set disableClientSideValidation="true" on all fields with validators on them.
Your QuerySaveDocument code looks something like this (assuming location is the field which is readOnly).
if (personDoc.getItemValueString("Location") == "") {
#ErrorMessage("The inherited location is blank and that is bad.");
return false;
}
return true;
With this, the field based validators will fire first and if they are all successful the QuerySaveDocument fires. This means if any field based validators fail, their messages will appear in your message area but the QuerySaveDocument message will not appear. QuerySaveDocument messages ONLY appear after all field based validators succeed.
When a read only field is rendered to the web browser it does not render using <input> tags but rather a simple <span> tag.
Validation can only be performed on proper input tags so the scenario you are experiencing is correct. There is no field for it to validate in read-only mode.
There is an option to 'display disabled in read only' which will render an <input disabled="true"> type tag for the field but I'm not sure off the top of my head is validation will work for those fields either because if a field is read-only then there really should be no need for any validation because your programmatically putting the value into the field and you should be validating it programmatically before you add the value.
In my Custom Control I have SSJS for a combobox onchange event to update an element using partial update.
The event is not fired when I'm in new document mode but fires when in edit mode.
I've tried other combinations such as Full Update, other events but it seems like Partial update is not working when in New Document mode.
Am I missing something here?
Using examples from: xpageswiki.com
Please advice
/Mike
I'll need to see the block for your radio button from your page's XML source.
These types of issues are sometimes caused by a bad event handler. In particular, depending on how you use Eclipse, there may be more that one block due to bugs in DDE. If you find more than one block, remove all but one, and try again. When this happens to me, I normally remove all blocks, then use the DDE UI to manually add the code and settings back.
When having required fields on the form and they are not filled in the event will not fire due the JSF phase. Setting the Server option "Process data without validation" to True will prevent the JSF to validate and continue with the event.