-
1. Re: It is possible to clear h:inputText with h:commandButton?
sivaprasad9394 Feb 13, 2014 9:34 AM (in response to edfromhadria)Hi,
For your issue try using,
render attribute(specify the component id need to be cleared )
Any of the keywords "@this", "@form", "@all", "@none" may be specified in the identifier list.
IF you are using ajax library or Seam means we have different options to clear it after updating.Like on complete.
Thanks,
Siva
-
2. Re: Re: It is possible to clear h:inputText with h:commandButton?
edfromhadria Feb 18, 2014 2:46 AM (in response to sivaprasad9394)Dear Siva,
I tried use the render attribute, but I don't know well how should I use it. Here is my xhtml page.
I'd like to when I click on the bti_ci button all inputtext and selection be clear, and the default.
Thank you,
Adrian
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <ui:composition template="/resources/master.xhtml"> <ui:define name="title">Create category</ui:define> <ui:define name="content"> <div id="additem"> <h:form id="hfrom1"> <rich:panel> <f:facet name="header"> <h:panelGroup> <h:outputText value="Create category group" /> </h:panelGroup> </f:facet> <h:panelGrid columns="3"> <h:outputLabel value="Main Category:" for="categoryGroupName" /> <h:inputText value="#{categoryGroupView.categoryGroupName}" id="categoryGroupName"> <rich:validator /> </h:inputText> <rich:message for="categoryGroupName" id="msgCategoryGroupName" /> </h:panelGrid> <h:commandButton id="btn_mc" value="Submit" action="#{categoryManager.insertCategoryGroup()}" /> <rich:notifyMessages stayTime="2500" nonblocking="true" /> <p /> </rich:panel> </h:form> <br /> <h:form id="hfrom2"> <rich:panel rendered="#{fn:length(categoryManager.listCategoryGroups_mg) > 0}"> <f:facet name="header"> <h:panelGroup> <h:outputText value="Create category item" /> <a4j:status> <f:facet name="start"> <h:graphicImage value="/images/ai.gif" style="height:12px;width:12px;" alt="ai" /> </f:facet> </a4j:status> </h:panelGroup> </f:facet> <h:panelGrid columns="3"> <h:outputLabel value="Main Category Group" for="categoryGroup" /> <rich:select enableManualInput="false" validatorMessage="Required to choose one Category Group." defaultLabel="Click here to select" id="categoryGroup" value="#{categoryGroupView.categoryGroupId}"> <f:selectItems value="#{categoryManager.listCategoryGroups_si}" /> <f:validateLongRange minimum="1" maximum="99" /> <f:validateRequired /> </rich:select> <rich:message for="categoryGroup" id="msgCategoryGroup" /> <h:outputLabel value="Add a category item:" for="categoryItem" /> <h:inputText value="#{categoryItemView.categoryItemName}" id="categoryItem"> <rich:validator /> </h:inputText> <rich:message for="categoryItem" id="msgCategoryItem" /> </h:panelGrid> <h:commandButton id="btn_ci" value="Submit" render="additem" action="#{categoryManager.saveCategoryItemToCategoryGroup}" > <a4j:jsFunction name="begin" render="additem" /></h:commandButton> <p /> </rich:panel> <p> <rich:messages ajaxRendered="true" /> </p> </h:form> </div> </ui:define> </ui:composition> </html>
-
3. Re: It is possible to clear h:inputText with h:commandButton?
liuliu Feb 18, 2014 3:21 AM (in response to edfromhadria)1. I think listener is called before action.
2. h:commandbutton dont do ajax thing, a4j:commandbutton is better.
3 why a4j:jsfuncion is nested by h:commandbutton?
-
4. Re: It is possible to clear h:inputText with h:commandButton?
edfromhadria Feb 19, 2014 1:58 AM (in response to liuliu)Dear liumin hu,
Yes, you right, the listener called before the action, this is a reason why I deleted the actionlistener already. I tried to do something with ajax is nesting the a4j:jsfunction by h:commandbutton. I'll try with a4j:commandbutton as you suggest.
Thanks,
Adrian
-
5. Re: It is possible to clear h:inputText with h:commandButton?
liuliu Feb 19, 2014 3:26 AM (in response to edfromhadria)I think what you need is put your code of listener at the end of your code of action if your backingbean is viewscope or upper.
h:commandbutton + f:ajx = aj4:commandbutton.
IMAO a4j:jsfunction is needed for some special situation.
-
6. Re: Re: It is possible to clear h:inputText with h:commandButton?
edfromhadria Feb 24, 2014 3:47 AM (in response to liuliu)Dear
Sorry for my late answer, I've tried this
<a4j:commandButton id="btn_mc" value="Save" action="#{categoryManager.insertCategoryGroup()}" event="click" execute="@none" render="categoryGroupName"/>
but still doesn't work well. I'm so newbie about this, but I find another way to solve this.
Well, at the action, in the insertCategoryGroup() method I've added this line:
categoryGroupView.setCategoryGroupName("");
Well, I think it is not the pretty solution, but it works for now.
Maybe I'll see another way later,
Thanks!