jsf - Primeface View with dynamic added Component -
i need dynamic view in primeface. view must build runtime , add primeface components.
in view had panelgrid , added elements backing bean. problem no setter called. added valueexpression , getter called, never setter.
my view
<?xml version="1.0" encoding="utf-8"?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:f="http://xmlns.jcp.org/jsf/core"> <h:head> <title></title> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <link href="#{request.contextpath}/resources/css/primefaces-9/theme.css" rel="stylesheet" type="text/css"/> <link href="#{request.contextpath}/resources/css/p_css.css" rel="stylesheet" type="text/css"/> </h:head> <h:body style="font-family: arial; font-size: 8pt;"> <h:form id="buttonform"> <p:calendar id="test" value="#{editor.dt_vraufnahmedatum}" mindate="#{editor.str_currentdate}" navigator="true" locale="de" pattern="dd.mm.yyyy" /> <p:selectonemenu id="seltest" /> <p:commandbutton id="reloadpanelgrid" action="#{editor.setuicomponents()}" value="new" /> </h:form> <h:form id="dynaform"> <p:panelgrid id="tiles" columns="1" > <h:outputtext value="hallo" /> <p:commandbutton value="submit" actionlistener="#{editor.storedatavr()}" process="dynaform"/> </p:panelgrid> </h:form> </h:body> </html>
my backing bean
package com._9.controller.global; import java.io.serializable; import java.text.parseexception; import java.text.simpledateformat; import java.util.date; import java.util.logging.level; import java.util.logging.logger; import javax.annotation.postconstruct; import javax.el.valueexpression; import javax.faces.bean.managedbean; import javax.faces.bean.viewscoped; import javax.faces.component.uiselectitem; import javax.faces.component.html.htmlpanelgroup; import javax.faces.context.facescontext; import org.primefaces.component.panelgrid.panelgrid; import org.primefaces.context.requestcontext; import org.primefaces.event.selectevent; @managedbean(name = "editor") @viewscoped public class editor implements serializable { private static final long serialversionuid = -33430593454354523l; private string str_text = ""; @postconstruct public void init() { } public string getstr_text() { return this.str_text; } public void setstr_text(string str_text) { this.str_text = str_text; } public void setuicomponents() { org.primefaces.component.inputtext.inputtext inpt_obj = new org.primefaces.component.inputtext.inputtext(); inpt_obj.setvalueexpression("value", createvalueexpression("#{editor.str_text}", string.class)); htmlpanelgroup tile = new htmlpanelgroup(); tile.setid("testpanelgroup"); tile.getchildren().add(0, inpt_obj); panelgrid tiles; tiles = (panelgrid) findcomponent.dofind(facescontext.getcurrentinstance(), "dynaform:tiles"); tiles.getchildren().add(2, tile); requestcontext.getcurrentinstance().update("dynaform:tiles"); } public valueexpression createvalueexpression(string valueexpression, class<?> valuetype) { facescontext facescontext = facescontext.getcurrentinstance(); return facescontext.getapplication().getexpressionfactory().createvalueexpression(facescontext.getelcontext(), valueexpression, valuetype); } public void storedatavr() { int = 0; } }
is problem in setvalueexpression setter not working.
greetings
gerald
in method setuicomponents() creating value expression "#{editor.str_text}" lower-case 't', getters , setters named capital 't'. may see propertynotfoundexception in application logs when click first commandbutton, indicating not able create value expression.
Comments
Post a Comment