-1

I have created a simple jsf apllication for file upload but instead of creating a jsf input file like this

<h:form id="fileToUploadForm" enctype="multipart/form-data">
    <h:inputFile id="fileToUpload"  required="true" f5:multiple="multiple"
           requiredMessage="No file selected ..." onchange="fileSelected();"
           render="FilesTable"/> 
    <h:commandButton type="button" onclick="uploadFile()" value="Upload" />
</h:form>

I want to create it programmatically and add it to the form. For ex : htmlform.getChildren().add(<File Component>)

pirho
  • 11,565
  • 12
  • 43
  • 70
saurabhiitr
  • 47
  • 1
  • 7
  • 3
    There are multiple Q/A in at least stackoverflow about creating components programatically. Please find them, try, keep track, mention etc. like requested in [ask]. Now it is sort of a question where you ask us to write code for you. – Kukeltje Dec 27 '18 at 11:14
  • @kukeltje i know and already done this with other components i just need the name of the class in my class if you could help. – saurabhiitr Dec 27 '18 at 12:02
  • There are api docs available for JSF and the source is open https://github.com/javaserverfaces/mojarra/tree/2.3.0/jsf-api/src/main/java/javax/faces/component. And if you know the classes for other components, it should not be too difficult via codecompletion in the IDE or via the api docs to find the class name (that is what I would need to do for you since I do not know it from the top of my head) – Kukeltje Dec 27 '18 at 12:23
  • https://github.com/javaserverfaces/mojarra/blob/2.3.0/jsf-api/src/main/java/javax/faces/component – Kukeltje Dec 27 '18 at 12:28
  • But more importantly, also read https://stackoverflow.com/questions/3510614/how-to-create-dynamic-jsf-form-fields – Kukeltje Dec 27 '18 at 12:43

1 Answers1

-1

Since I was using jsf 2.1 earlier I didn't find the class,

 javax.faces.component.html.HtmlInputFile 

is the class present in jsf API 2.2 onward and

 org.omnifaces.component.input.InputFile

is the class I found in omnifaces as an alternate.

saurabhiitr
  • 47
  • 1
  • 7