0

I have JSF page with datatable. In this datatable one cloumn I used to display inputtext field. My problem is how to get all inputfields data from JSF and how to store coming inputfield data into an array or a list.

My code is:

JSF file:

    <h:dataTable value="" var="" >
        <h:column>
                <h:inputText value="#{storingManagedBean.list}"/>
        </h:column>
    </h:dataTable>       

storingManagedBean.java:-

public class StoringManagedBean{

  public Float[] getList() {
    return list;
  }

  public void setList(Float[] list) {
    this.list = list;
  }
}

in the above code I'm getting null or empty values.

Sam R.
  • 16,027
  • 12
  • 69
  • 122
Rookie007
  • 1,229
  • 2
  • 18
  • 50
  • 1
    JSF already does that transparently. What problem exactly are you facing? Where's your code? You must have made some mistake in there if JSF was unable to do the job it's designed to perform. Taking some time to go through a decent JSF book/tutorial would also be worth the effort as you seem to miss some crucial fundamental knowledge. – BalusC Feb 13 '14 at 07:33
  • 1) Your `storingManagedBean.list` should be String. You can transform that String into array or list (if it possible) in submit action method. 2) `var` represent object = item of list (for which dataTable is built) and store your input in member data of this object. – Vasil Lukach Feb 13 '14 at 22:57
  • thanks Vasil Lukach to replay my post i did change my Float type list to String type list and main thing is am not clear about your 2) point i want an example code code also – Rookie007 Feb 14 '14 at 04:27

1 Answers1

0

I think the code you gave for StoringManagedBean isn't complete. What makes that class a Managed Bean? Also where is the list defined? Can you try making it a String.

Try this:

@ManagedBean
@RequestScoped
public class StoringManagedBean{
  String list; 
  public String getList() {
    return list;
  }

  public void setList(String list) {
    this.list = list;
  }
}
Saurabh Patil
  • 4,170
  • 4
  • 32
  • 33