Hi Mike,
I agree that we can do the way u have suggested...but what is wrong in my code and why im not able to get any components created in the datatable...
Here's the code:
JSP
---------------------------------
<h:dataTable id="mainTable" binding="#{dynamicQuestions.dataTable}" value="#{requirementBean.questionList}"
var="questions" border="1"/>
 
Java method
-------------------------------
  public UIData getDataTable()
{
Application application = FacesContext.getCurrentInstance().getApplication();
        UIViewRoot uiViewRoot =  FacesContext.getCurrentInstance().getViewRoot();
         HtmlDataTable dataTable =(HtmlDataTable)uiViewRoot.findComponent("mainTable");
//------------------- adding HtmlOutputText ---------------//
        String vbStr = "#{questions.questionData}";
        ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(vbStr);
        HtmlOutputText output = new HtmlOutputText();
        output.setId("HtmlOutputText1");
        output.setValueBinding("value", vb);
   
//------------------- adding HtmlSelectOneMenu ---------------//
        vbStr = "#{questions.itemList}";
        vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(vbStr);
   
        HtmlSelectOneMenu hsom = new HtmlSelectOneMenu();
        hsom.setId("HtmlSelectOneMenu2");
        hsom.setValueBinding("value",vb);
 //------------------- adding HtmlSelectManyListbox ---------------//

        vbStr = "#{questions.itemList}";
        vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(vbStr);
   
        HtmlSelectManyListbox hsmlb = new HtmlSelectManyListbox();
        hsmlb.setId("HtmlSelectManyListbox3");
        hsmlb.setValueBinding("value",vb);

    //datatable column
        UIColumn column = new UIColumn();
        column.setId("UIColumn4");
        column.getChildren().add(output);
        column.getChildren().add(hsom);
        column.getChildren().add(hsmlb);
   
       dataTable.getChildren().add(column);
 return dataTable;
}


Mike Kienenberger <[EMAIL PROTECTED]> wrote:
On 7/13/06, ved.gunjan <[EMAIL PROTECTED]>wrote:
> My requirment is that i have to create a dynamic datatable and which
> contains listing of Questions and its respectives Answer. These questions
> and answer come from the server and along with the answer i also get the
> answer type , which tells what is the type of the UIComponent that is
> associated with the answer say input text,select many,select one etc., so i
> have to dynamically create these UIComponent inside the datable based on the
> answer type.

There's a much easier way to do this.


[...]



Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

Reply via email to