I am trying to build a wizard type form using Reactive Forms. Following is a snippet of my code
<form [formGroup]="pizzaForm" novalidate>
<wp-wizard navBarLocation="top">
<wp-wizard-step title="Dough">
<input type="text" id="dough" [formControlName]="dough">
wizard and wizard-step are working without forms.
When I implement them with Reactive Forms and run the application, I'm seeing errors like below.
Cannot find control with name: '[object Object]'
I'm assuming this is because dough formControlName is not immediate child of pizzaForm formGroup. Not sure though. If that is the cause, how do I fix this problem? I have few fields in each wizard steps and I think all the fields should still belong to the same form so I can track the form validity. Or may be I should have different forms for each wizard step ?
Please let me know if more information is required to understand the issue.
I mistakenly used [formControlName] instead of formControlName
Related
we have autocomplete="off" in jquery but not finding to set in gwt xml file.Can someone help me to set autocomplete to false.
<f:FieldLabel labelSeparator="" ui:field="userNameLabel">
<f:widget><f:TextField width="300" ui:field="userName" /></f:widget>
</f:FieldLabel>
Textfield doesn't have autocomplete attribute to set.
What ui library are you using?
For example if you are using vanilla gwt you could get the Element and set the attribute autocomplete="off" manually
http://www.gwtproject.org/javadoc/latest/com/google/gwt/dom/client/Element.html#setAttribute-java.lang.String-java.lang.String-
You could create a Composite that wraps the field and set this automatically, then create instances of TextFieldNotAutocomplete for example
http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/Composite.html
Recently, when I use React&material-ui to make a form, I find that many components do not have 'name' property, such as 'SelectField'. So I must get the value through a method. Is material-ui suitable for implementing a form? If the answer is yes, can you give me a intact example which uses some components such as 'TextField', 'SelectField', and how do I submit it?
I could recommend connectin material-ui with redux-form:
http://redux-form.com/6.8.0/examples/material-ui/
Works fine as long as you pass component representing material-ui form into the Field from react redux
import { Field } from 'redux-form/immutable';
import TextField from 'material-ui/TextField';
<Field
name="username"
id="username"
type="text"
placeholder="Username"
label="Username"
required
iconName="person"
component={TextField}
/>
And then you would have form values existing in redux state.
This actually is not a material-ui specific issue i believe. You'll be in the same boat if you use simple <input> elements.
Basically what you want to do is get/set the value of a text box / checkbox when a user does some action or clicks submit. Material-ui just lets you do pretty, reusable and designed components so that you wont have to write them yourself.
To work easily with forms you would have do some additional coding from your side. I also suggest the great library redux-form but it would require you to also implement redux in your app (A great thing by itself but i dont know what are your requirements).
If you want another option then you can use https://github.com/christianalfoni/formsy-react which is another great and popular library for managing forms and doesnt require redux
If you want to do things yourself then you can use recommendations from https://facebook.github.io/react/docs/forms.html which in general tell you to have controlled components.
One final thing. Dont be afraid to use additional libraries and modules. The whole point in having hundreds thousands of modules is for people to use them =]
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.
So here's the problem. We have some big dojo forms created using Zend_Dojo_Form. The problem is that validation, while working per element, does not work on any of the submit buttons. Due to the inflexibility of the standard layouts, we're compelled to use viewscripts.
I thought I had the whole thing working fine, that was until I needed to make sure that when you went from page to page of the multipage form using the quick links that it submitted the current page (with validation.)
I noticed that when I force-fired the click event on the submit button, no validation was occurring (or rather, there was no preventing the form submission if there were invalid values. Those values just were not submitted.)
So I looked at some tutorials where I found that the form is validated by calling
dijit.byId('form-id').validate();
or the shortcut I was looking for, primarily (originally)
dijit.byId('form-id').submit();
Neither of which are functions, since the byId is returning undefined. What this means is our viewscript - or whatever the whole process is - generating dojo forms with Zend is partly voodoo anyway - does not actually generate the dojo form dijit.
So how does one do this in a viewscript? As in, what sort of php calls or attribs does one attach to the form tag to get it to be interpreted by Dojo to be the basis for a form dijit?
Here is the code from the viewscript:
<form action="<?= $this->escape($this->element->getAction()) ?>"
method="<?= $this->escape($this->element->getMethod()) ?>"
id="case-record-form">
This sounds very similar to a problem I had. If I rendered the form by echoing it, validation worked, but when using a viewscript it would not. I discovered that when using a viewscript, Zend does not add the form to its zendDijits array, so you have to do it manually.
Add something like:
$script = 'zendDijits.push({"id":"MyFormId","params":{"dojoType":"dijit.form.Form"}})';
$this->headScript()->appendScript($script);
at the top of the viewscript.
I Have a hidden box in my HTML. How I can get it value in my GWT when onModuleLoad??
the hidden box will content a value pass from another page. Now I can see the hidden box content the value but I fail to get the value in my GWT onModuleLoad.
HTML page:
<%
String sSessionID=request.getParameter("NA_SessionID");
if(sSessionID==null)
session.setAttribute("NetAdminSession",(String)session.getAttribute("NetAdminSession"));
else
session.setAttribute("NetAdminSession",sSessionID);
%>
<form name=frmMain method=post>
<input type=hidden name=NA_SessionID name=NA_SessionID value="<%=(String)session.getAttribute("NetAdminSession")%>"></input>
</form>
You can access any element in the DOM by using the GWT DOM Class. For example, if your hidden box has the id "NetAdminSession", you may use the following to access the hidden box...
DOM.getElementById("NetAdminSession");
To: Geoffrey Wiseman
my HTML file is in the GWT HTML.. but I change it to JSP file instead of HTML
To: prometheus
Thanks you information, I will give it a try now.
I'm not sure what your overall approach/architecture is, but it might also be helpful to look into some of the new features added in GWT 2.0. Specifically, Declarative Layout with UIBinder. With this you can actually construct your user interface with declarative XML instead of using pure Java. I would steer away from creating too much of your UI in the actual HTML file since it will be easier to control those UI elements if you construct them in your GWT code. You can still stick to good MVC principles if you break your classes/code up the right way.