Array list and jsf

I use jsf and I have an Arraylist of string that I want to put at an input text.

 thefiles files=new thefiles();
 File dir = new File("C:/dimis/all/");
		String[] children = dir.list();
		if (children == null) {
// Either dir does not exist or is not a directory
		} else {
for (int i=0; i<children.length; i++) {
 files.setFiles( children[i])  ;
  ArrayList<String> myfiles=files.getFiles();
        <&#37;  Iterator iter = myfiles.iterator();
     while (iter.hasNext()) { %>
     <h:inputText value="#{}"></h:inputText>
     out.println("string " +;
      <% }

This code does not work, what is wrong?

I think you need to take a step back here, there are several problems with this but what you’re doing won’t work in JSF. You can’t mix scriptlet and JSF tags. Even mixing JSTL and JSF tags won’t necessarily work. Variables declared in the scriptlet (<% %>) won’t be recognized as JSF EL (#{}).

Another big problem, you’re calling twice in the same loop. You’re going to get some very interesting results with that.

Also are you using a managed bean? The arraylist should be a property of a managed bean and then you should use a component like tomahawk’s datalist component to loop through. Although I don’t really understand your logic here. Why would you want to bind filename to an input text? Should that be an output text maybe?

This code is just a first “test” of that I want to do.
A list of files that user will download from server.
I am sure I have to make a bean that will have the files (thefiles class has an arraylist as is understood) and maybe will be send at page as a parameter or something from a servlet.
So this page will have an arraylist (or what else?a class?) to iterate and have checkboxes with files (at last version).
So jsf does not support form elements with dynamic values?

JSF definitely supports dynamic values, but just not in the way you’re trying to use it.

To get a listing of the files with checkboxes you’d need to use a datalist with checkboxes inside and output text (not input) for the filenames.

something like

 <t:dataList var="file" value="#{someBean.allFiles}" layout="unorderedList">
   <t:selectBooleanCheckbox value="#{someBean.selectedFiles[file]}"/>
   <t:outputText value="#{file}"/>

and a backing bean

public class SomeBean {
 private List<String> allFiles;
 private Map<String,Boolean> selectedFiles;
 // + getters and setters

You have to add somebean to the faces-config file, sorry don’t feel like typing that one out…

So with that JSF will generate a list (<ul><li> … ) with each file and a checkbox next to it. Then later you’ll have an action method and the Map selectedFiles will have all the files as keys and values will be Booleans, that ones that are true have been selected.

That’s just one way to do this. The t: tags are from myfaces tomahawk.

Thang you for the replay.
There are actually my first steps at jsf so I have to look at apis,tutorials etc deaper