0 Replies Latest reply on Apr 9, 2011 3:43 AM by vata2999

    creating s:fileUpload Dynamically

    vata2999

      Hi,


      I'm creating s:fileUpload dynamically but i've got this exception


      Caused by javax.servlet.ServletException with message "#{addComponent.addcmp}:
      
       java.lang.ClassCastException org.jboss.seam.ui.component.html.HtmlFileUpload cannot be cast to 
      
      org.jboss.seam.ui.component.html.HtmlFileUpload



      code



      import javax.faces.application.Application;
      import javax.faces.context.FacesContext;
      import javax.faces.component.UIComponent;
      import javax.faces.component.html.HtmlInputText;
      import org.jboss.seam.ui.component.html.HtmlFileUpload;
      
      
      public class AddComponent {
      
           protected UIComponent component;
      
           
           public UIComponent getComponent() {
                return component;
           }
      
      
           public void setComponent(UIComponent component) {
                this.component = component;
           }
      
      
           public AddComponent() {
           }
           
           
           public String addcmp(){
                
                FacesContext fc = FacesContext.getCurrentInstance();
                Application app=  fc.getApplication();
      //          HtmlInputText comp = (HtmlInputText)  app.createComponent("javax.faces.HtmlInputText");
                HtmlFileUpload comp = (HtmlFileUpload)  app.createComponent("org.jboss.seam.ui.FileUpload");
                
                
                component.getChildren().add(comp);
                return null;
           }
           
           
      
      }



      i can add other jsf component successfully How can i solve this problem ?


      Thanks in advanced