Friday 15 March 2013

jsf - Insert primefaces dataTable rows based on p:inputText fields -


I need a cleaner to apply this case.

  • About 10 primetime inputtics
  • Create a primetime data databases
  • Contact an entity whose name is 10 properties (name, Description, etc ...)

  • Best way to add rows to data after typing in the inputtax and clicking on the button. ? (I can not release data on DB. Only add new data typed in data to enable new line) < / Ul>

    Thanks,

    Then you will do this (10 times) to get your results ):

    Whatever you wish to start with specifying the beans, here we will be general to make useful for the good people here:

      package pack ; Import javax.faces.bean.ManagedBean; Import javax.faces.bean.RequestScoped; @Managed Bean @ configuration public class unit {Private string unit property; Public string getEntityProperty () {return entity property; } Public Zero Set Entityproperty (string unitproperty) {this.entityProperty = entityProperty; } Public entity (string e) {this.entityProperty = e; }}   

    Then you use unit in this verb (which I have said to be bean ). We do this to fill the list which dataTable we will repeat to make our rows here is the bean:

      package pack; Import java.util.ArrayList; Import javax.faces.bean.ManagedBean; Import javax.faces.bean.RequestScoped; @ManagedBean @RequestSpeoped public square bean {Private string property; Private Arrestist & lt; Unit & gt; List; Public Array List & Lieutenant; Unit & gt; GetList () {Return List; } Public Zero Set List (Arrelist & Unit; Unit & gt; List) {this.list = list; } Public string getProperty () {return property; } Public Zero Setproperty (String property) {this.property = property; } Public Bean () {List = New Arrestist & lt; Unit & gt; (); } Public Zero Show IndataTable () {list.add (new entity (property)); }}   

    Finally, we come to the presentation page, a tour usually gives you an idea of ​​how to use and how:

     < Code> & lt; XML version = '1.0' encoding = 'UTF-8'? & Gt; & Lt ;; DOCTYPE HTML PUBLIC "- // W3C // DTT XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" xmlns: h = "http://java.sun.com/jsf/html" xmlns: f = "http: // Java Sun.com / Jsf / core "xmlns: p =" http://primefaces.org/ui "& gt; & Lt; H: top & gt; & Lt; Title & gt; StackOverflow & lt; / Title & gt; & Lt; / H: top & gt; & Lt; A: Body & gt; & Lt; H: form & gt; & Lt; P: inputtext value = "# {bean. Property}" /> & Lt; P: command button value = "show in data tab" action = "# {bean.showInDataTable}" update = "datable" / & gt; & Lt; P: dataTab id = "datatable" value = "# {bean.list}" var = "o" & gt; & Lt; P: column & gt; & Lt; H: output text value = "# {o.entityProperty}" /> & Lt; / P: column & gt; & Lt; / P: DataTable & gt; & Lt; / H: form & gt; & Lt; / H: Body & gt; & Lt; / Html & gt;   

    So you optimize it according to your needs, it should run properly after you have the properties determined by your unit equals (To say this, in your case, 9 beans and more property for the unit and an adjusted manufacturer for them).

    Good luck.

No comments:

Post a Comment