dynamic feedback with JSF & jQuery / Javascript - forms

We are working on a project with JSF and PrimeFaces and we are looking to add dynamic inline validation on our forms. I'm not sure if PrimeFaces can handle this (correct me if I am wrong) so I am looking for some alternatives
Does anyone know of any plugins we could use to do this? Prefer something that incorporates JSF too...
I'm not a developer but a UX guy so sorry if some of the terminology is incorrect.

Standard JSF supports server side validation by ajax (live example here) and PrimeFaces definitely also supports it (live example here). You can add <f:ajax event="blur" render="message_id" /> inside input components to perform validation directly on blur (see also this tutorial).
<h:inputText id="foo" value="#{bean.foo}" required="true">
<f:ajax event="blur" render="foo_message" />
</h:inputText>
<h:message id="foo_message" for="foo" />

Related

What is the syntax to use React fragments in Reason-React

There is this old chat that suggests writing your own fragment wrapper, but I understand that fragment should now be natively supported.
However I couldn't quickly find the correct syntax for it.
Example of what I'm looking for:
<fragment>
<button label="foo"/>
<button label="bar"/>
</fragment>
Here is the official documentation page on reason-react and fragments.
The syntax for using React fragments in reason-react is this:
<>
<button label="foo"/>
<button label="bar"/>
</>
The terse syntax may be easy to miss if you are looking hard for something like <Fragment> (this is what happened to me). I first found the answer in the release notes for version 0.5.0

Integrate Htmls into GWT

We have a web application that its UI is based on GWT.
We are pretty satisfied from the technology, but we have one major problem: We get html files from our designer, and it takes a lot of time to integrate them into our GWT code.
Is there a quick way or rules to do that?
For instance, I would like to take the html, put it almost "as is" in a ui.xml file, and then start binding the components to UiBinder fields.
What is the quickest way to do that? What should I do with the CSS and JS files that I get?
I need some guidelines to make this conversion, so it will be quick & easy.
We have the same problem. It might be hard for a designer to get used to GWT widgets. But he'll have to forget about making HTML proof-of-concepts and using GWT directly.
We didn't overcame the difficulty. As a result, many GWT features are under-used (like CSSResources, or GWT-Bootstrap layout capabilities).
I would advise to have him learn the xml of GWT widget libraries.
You can also start by using GWT Designer. This way he can still do the design, learn the XML bit by bit, and you can still work on wiring the components.
Of course it is a slow process. People don't change old habits instantly.
Errai seems to fit your requirements.
Basically is uses regular HTML5 templates, binded to GWT logic.
"Create standard conform HTML5 templates or use existing HTML and CSS files to design your web and mobile applications."
http://errai.github.io/
Here is an example of a sign-in page:
<!DOCTYPE html>
<link rel=stylesheet href="css/TodoList.css">
<div data-field="main">
<h1>Get it done with Errai.</h1>
<div class=form>
<p class=error data-field=loginError>
Login failed. Please check that your email address and password were entered correctly.
</p>
<input type=text data-field=username placeholder="Email">
<input type=password data-field=password placeholder="Password">
<button data-field=loginButton>Sign In</button>
<p>New here? Sign up in seconds!</p>
</div>
</div>
source
(p.s. I've never used it, yet)

How to use more than one JSF form

I have a Java EE 7 project and in web application part I am trying to open JSF forms.
However when I run it, it just sees the initial form.
How can I enable it to reach other forms?
Small example from my code:
<body>
<h:form id="firstForm" prependid="false">
...
</h:form>
<h:form id="secondForm" prependid="false">
...
</h:form>
</body>
This answer helped me a lot. And also there were some referance problem. After correcting them, I can see all the form structure.
I know the code above is not nested form structure, but for other people who are curious about this issue, you cannot make nested forms in HTML5 (for both <h:form> and <form>). So be careful to your template.
Good luck!

PrimeFaces elements that need h:form to be updated

I need list of primefaces elements that need to be wraped by <h:form> in order to be updated by any action of <p:ajax>some primeface elements even if they have id and in <p:ajax update="thisID"> it still needs an <h:form> with an id in ordered to be updated so which elements need <h:form> and whick not
To the point, all components implementing the EditableValueHolder interface and the ActionSource interface needs to be enclosed in an UIForm component.
In the aforelinked Javadocs you can find in the "All Known Implementing Classes" indications which components implement them. If you look closely, then you'll notice that it are all input components like inputText, selectOneMenu, etc and command components like commandLink, commandButton, etc. In the PrimeFaces API documentation, for example the InputText which represents the <p:inputText> implements EditableValueHolder, so it should be placed in a form.
It's also exactly the same rerequirement as in plain vanilla HTML has, the HTML <input>, <select>, <textarea>, etc should go in a <form> in order to get value to be sent to the server side. HTML is also what JSF ultimately produces, after all.
As to updating elements by ajax, it's not true that the to-be-updated components needs to be placed inside a form. You can perfectly update content which is outside the current form. You can even update other forms.
This is a slight modification to PatrickT's Answer. You are able to update things outside the form also. But data you want to submit should be part of the form afaik.
<p:messages id="outsideForm" showDetail="true"></p:messages>
<h:form id="kalle">
<p:messages id="insideForm" showDetail="true"></p:messages>
<p:inputText required="true"></p:inputText>
<p:commandButton value="submit" update=":outsideForm,insideForm"/>
</h:form>
Every component submitting/receiving Content from/to a backing bean needs to be wrapped by <h:form>.
So everything you want to update or every Button / Link setting something needs to be inside a form. Also this isn't a Primefaces thing. This rules apply for normal JSF too.

ColdFusion 10 form variable functionality change relating to case of variables

We're just looking at porting a legacy script to ColdFusion 10 and I believe I have come across a bug/change in functionality relating to the use of multiple form fields using the same name. In ColdFusion 9 these would have been appended to the relevant variable with commas, but in ColdFusion 10, if the case of the variables is different one field will overwrite the other.
The following test code:
<form action="index2.cfm" method="post">
<input type="hidden" name="test" value="1" />
<input type="hidden" name="TEST" value="0" />
<input type="submit" />
</form>
<cfdump var="#form#">
Produces on ColdFusion 9
TEST = 1,0
On ColdFusion 10:
TEST = 0
Has anyone else experienced this behaviour and knows whether it is a bug or intended functionality? I know the application shouldn't be using the same variable name in different cases, so will look at changing this, but just wondered if anyone had any more information on the issue.
Edit
I have submitted this bug to Adobe at https://bugbase.adobe.com/index.cfm?event=bug&id=3298179
#Russ
This feature is indeed just that a feature. I believe you've missed the point in the above post that specifying the same field name with different case no longer passes a list result.
One of the main things I and many have used this functionality for in the past is checkboxes. A group can have the same name so that your validation is easy yet different values so CF can process which ones have been ticked before form submission(obviously unticked items aren't passed into the list).
This bug appears to have been confirmed by Adobe in as Bug #3298179. It is reported as fixed in build 283412 and currently in the testing phase. I will update this answer with the relevent hotfix information once this has been released publicly.
That "feature" has been around since at least CFMX 6.1. I blogged about it back in '08: http://cfruss.blogspot.com/2008/01/passing-multiple-same-named-arguments.html