How to check content validity in Ace.js - ace-editor

I am using Ace.js for JSON and I need to check if content is valid every time I click a button. Ace.js has such validator on keyup. Therefore there should be a method to check content validity and return a Boolean.

Related

How to submit the value in an inputtext field by setting autoSubmit to false

I have an ADF form based on a VO and I need to check whether a particular field is null or not on click of a Submit button. For this, i set autoSubmit to true and get the value entered to a variable in my bean.On click of Submit button , i check if the variable is null or not and display error faces message if the variable is null. But how do i get the value entered in the form to a variable in the bean with autoSubmit set to false?
Why do you have it turned on in the first place? And why do you want to turn it off? Are you clear on it's functioning and why to use it?
Autosubmit is used to support Partial-Page Refresh.
If you don't need PPR, Just turn it off. The value will still be available once the submit button is pressed. Read about it here.
An input component that has its autosubmit property set to true also
performs a partial submit of the form. However, this time it doesn't
submit the entire form but only the component that triggers the submit
plus components referenced it in their PartialTriggers property.
Autosubmit is not required to access values entered into input components on the screen. Autosubmit submits only the field and also bypasses certain phases of the page processing lifecycle.
if you turn autosubmit off, the entire page - all the fields - is submitted and goes through the complete page processing lifecycle, so you have access to all input fields.
Docs here.

In EWL, can you alter a form item’s contents after a failed validation?

On an EWF page, is it possible to alter the content of a form item during validation (when a validation fails)? For an example: say you have a text box that you want to be spell checked before it gets entered into the database. You use the modification's GetSpellCheckedWordTextFormItem to get the form item, and you want to replace what the user enters ("teh") with a likely suggestion ("the") when the validation fails to find a word it knows. Then the user sees the validation error ("Is this the word you meant?"), looks at it and corrects it or not, then re-submits.
Is there a way to do that? If so, how?
The specific answer to your question is no, you can't alter any form values if validation fails. To implement this, you'd need to let the validation succeed and let the data get modified. As part of the validation/modification, you could set a piece of page state that causes the next loadData pass to display the "is this the word you meant?" message near the spell-checked form item. Of course, you would have already saved the corrected text.
Alternatively, you could use PostBack.CreateIntermediate to make a post-back that only runs the spell-check, puts the corrected text in page state, and displays "is this the word you meant?". You'd set that post-back to fire when the user tabs out of the text box, and then you'd have the main post-back grab the corrected text from page state and save it in the database or other durable storage.

Richfaces prohibit event by passing by user

I have a text box and value change listener on it. And there is a save button. The user avoids/bypasses value change listener by directly editing text box value in html code and then saves it. How can i prohibit the user, so that he/she is not able to change value this way? And thus make sure that value change listener is always called.
I am looking for some generic mechanism to stop such cases on all inputs/and event listeners.
Thanks
You need to accept that the user can actually do EVERYTHING he wants with his client (the browser). He can disable Javascript, remove inputs completely, change validation or call Ajax functionality manually. He might not even use a browser and send an HTTP request using a command line tool.
It is just impossible to prohibit such things.
On the other hand I think that in case you use a valueChangeListener on your h:inputText, then it should be called in any case, because it will be evaluated serverside. It might be that you edited it the wrong way and the value actually doesn't change when you save the content of the form. (Check that the value really gets set by adding a breakpoint to your setter).
If you use Ajax functionality using <f:ajax> with event="change" and a listener, then there is no way to prevent bypassing it by manually editing the html. Either check for the changed value in your save method, or use the valueChangeListener instead.

How can I change my URL before loading my view?

I have a CodeIgniter webpage containing (i) a list of items and (ii) a form to add a new item or edit the details of a selected item.
To select an item for editing, I have an "edit" anchor tag with a hyperlink ending with ?id=nnn. This results in a GET request that populates the detail fields of my selected item and redisplays the list. My URL now contains site_address/index.php/country?id=151.
When I submit my changes the list is updated correctly but my URL remains unchanged. What do I need to do in my controller to remove "?id=151 after my update was successful?
Thanks for your help.
I'm not sure of everything you are doing, so I'll just answer directly:
in your controller, after you update, you can:
redirect('site_address/index.php/country');
Does that fit what you mean?
Through php there's no way to change URL after request expect redirecting
redirect('controller/method');
and you can success message using session flash message after redirecting, if that what makes you want to reload the view

Intercepting Save in Core Data Document

I have a window with a small text box, bound to a Core Data attribute. The value the user enters into the text box needs to be within certain parameters. These parameters are dynamic. If the entered value is outside of the parameters, a dialog box is displayed asking if the user wants to revert to a previous value, set the value to a minimum, etc. I have implemented the controlTextDidEndEditing method to intercept and validate the value the user enters. My problem is when the user saves or quits. The user can enter a bad value, select save or quit and value is saved, bypassing the validation. Is there a way to have my validation method called before a save? Thanks!
Instead of using the text field delegate, you should instead implement validation in your NSManagedObject subclasses. You can then enforce what values are valid and return an appropriate error message if an invalid value is entered. Doing it this way means that the model is responsible for enforcing validity, which is the logical place to do it.
There is more info about validation in the appropriate section of the Core Data documentation.

Resources