Form validation and update of htmlInputText fields
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
Form validation and update of htmlInputText fields  XML
Forum Index -> Components
Author Message
Baleyba

Joined: 16/11/2006 00:00:00
Messages: 110
Offline


Hi,

I have one problem.

On my application I have some forms.
They appear when I click on a "add" button.

The forms have some inputfields and 2 buttons: "Validate" and "Cancel".

When I click on "Cancel", I want that all the fields become empty and hide the form.

But my form has got required fields... and have validation process...

And when I press cancel, the form is hidding, but the field stay the same when I click again on "add" to show the form... even if I call the onDemandRenderer...
If I remove (immediate="true"), It works only when all the required fields are completed.

I don't understand how to do...

Unfortunately, if I use the "reset" commandButton, it works, but the "action" and "actionListener" aren't called...

Thanks for your help
regards
Bal.

Here are some part of code:


In the bean
...
public void cancelAddADataModelButtonListener(ActionEvent e) {
this.title ="";
this.description = "";
this.helpMessage = "";

this.generalController.requestOnDemandRender();
}

public void BlindDownEffect() {
this.setContentPanel(ManageDataModelVariable.addDataModelPanel);
this.setButtonAddDisabled(true);

this.effect = new BlindDown();
}
...


and in the jsp
...
<ice:form>
<ice:panelGrid columns="3" rowClasses="textFieldNameRow, textFieldCommentsRow, textFieldCommentsRow" >
<ice:outputText styleClass="propertyLabel" value="Title:" />
<ice:inputText size="50" required="true" value="#{dataModelController.title}" partialSubmit="false" id="title" />
<ice:message for="title" style="color: red;" />

<div style="padding-top:5px;">
<ice:outputText styleClass="propertyLabel" value="Description:" />
</div>
<ice:inputTextarea id="description" value="#{dataModelController.description}" cols="20" rows="4" partialSubmit="false" style="width:280px;height:80px;overflow: auto;" />
<ice:message for="description" style="color: red;" />

<div style="padding-top:5px;">
<ice:outputText styleClass="propertyLabel" value="Help message:" />
</div>
<ice:inputTextarea id="helpMessage" value="#{dataModelController.helpMessage}" cols="20" rows="4" partialSubmit="false" style="width:280px;height:80px;overflow: auto;" />
<ice:message for="description" style="color: red;" />

<ice:commandButton value="Add" type="submit" actionListener="#{dataModelController.validateAddADataModelButtonListener}" action="#{dataModelController.BlindUpEffect}" />
<ice:commandButton value="Cancel" type="submit" immediate="true" actionListener="#{dataModelController.cancelAddADataModelButtonListener}" action="#{dataModelController.BlindUpEffect}" />

</ice:panelGrid>
</ice:form>

 



JBoss 4.2.3 | Java 1.6.0_16 | IceFaces 1.8.2
eashwaranp

Joined: 12/02/2007 00:00:00
Messages: 135
Offline


If I'm understanding this right, you want the fields to get reset when you press the cancel button, correct? Pls see http://wiki.apache.org/myfaces/ClearInputComponents page. It talks about setting the submitted value and local value to null.
brad.kroeger

Joined: 26/10/2004 00:00:00
Messages: 295
Offline


Here is an implementation of a reset button under similar circumstances:

<ice:commandButton actionListener="#{visitor.user.resetFields}"
immediate="true" />

resetFields method:

Code:
     public void resetFields(ActionEvent ae) {
         UIComponent base = ae.getComponent();
         UIComponent parentForm = base.getParent();
         
         while (!(parentForm instanceof HtmlForm)) {
             parentForm = parentForm.getParent();
         }
         
         clearSingleField(parentForm, "firstName");
         clearSingleField(parentForm, "lastName");
         clearSingleField(parentForm, "email");
     }
 


And the clearSingleField method:

Code:
     private void clearSingleField(UIComponent parent, String id) {
         try {
             UIInput toClear = (UIInput)parent.findComponent(id);
             toClear.setSubmittedValue("");
         }catch (Exception ignored) {
             /* Intentionally ignored - if this fails the one value won't be cleared */
         }
     }
 

Brad Kroeger
Developer
ICEsoft Technologies, Inc.
[Email]
eashwaranp

Joined: 12/02/2007 00:00:00
Messages: 135
Offline


Also pls see related post http://www.icefaces.org/JForum/posts/list/4179.page
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team