jsf - Submit form without attached file -
i want create jsf form attached file. give option form users submit without attach file. don't want mandatory.
<h:form id="form" enctype="multipart/form-data"> <div class="string"> <label class="name"> <h:inputtext id="name" value="#{contacts.name}" pt:placeholder="name*:"/> </label> </div> <label class="message"> <h:inputtextarea value="#{contacts.comment}" pt:placeholder="comment*:"/> </label> <h:inputfile id="filetoupload" value="#{contacts.file}" required="true" requiredmessage="no file selected ..."/> <h:commandbutton value="upload" action="#{contacts.upload()}"> <f:ajax execute="filetoupload" /> </h:commandbutton> <h:message showdetail="false" showsummary="true" for="filetoupload" style="color:red"/> <div class="btns"> <h:commandlink id="submitlink" class="link" value="submit" action="#{contacts.sendemail}" > <f:ajax render="@form" execute="@form" onevent="handledisablebutton" resetvalues="true"/> </h:commandlink> </div> <h:outputtext id="output" value="#{contacts.result}" /> </h:form>
is there way implement because if try submit form message no file selected ...
? when attach file using button upload button no message appears successful file upload.
you have inputfile
required. why have upload first always.
also, if not seeing message it's because not rendering again h:message
. try using in managed bean:
facescontext.getcurrentinstance().getpartialviewcontext().getrenderids() .add("idmessage");
Comments
Post a Comment