I am trying to dynamically add Labels and textfields from Primefaces to my webpage. I want to use JQuery. Until now I realize the same task with Primefaces only and it works quite well but has some beahaviour I want to avoid.
<!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
 <h:head>
<script type="text/javascript">
      $(document).ready(function() {
         var counter = 2;   
         $("#addButton").click(function(){
        var newTextBoxDiv = $(document.createElement('div')).attr("id",'TextBoxDiv' + counter);
            <!--
               This line causes trouble. If I use it nothing is rendered on page. 
               If I use <h:inputText /> the page is rendered but the functionality does
               not work
            -->
            newTextBoxDiv.html("<p:inputText />"); 
        newTextBoxDiv.appendTo("#TextBoxesGroup");
        counter++;
         });
      });
   </script>
</h:head>
<h:body>
<ui:insert>
    <ui:include src="/protected/header.xhtml" />
</ui:insert>
<h:form>
    <div id="test"></div>
    <div id='TextBoxesGroup'></div>
    <input type='button' value='Add Button' id='addButton' />
    <input type='button' value='Remove Button' id='removeButton' />
</h:form>
</h:body>
</html>
I would appreciate some hints on tutorials on the subject or if it is a simple error in my code. a solution for this prob. Thank you in advance :)
 
     
    