jsf - commandButton actionListener not working on primeFaces CRUD Generator netbeans plugin nbpfcrudgen-0.15.2-7.3.1impl.nbm -
i'm testing primefaces crud generator on netbeans.
web site: primefaces crud generator netbeans beta
is not working actionlistener when push save button of create.xhtml page. same happens when edit row. there nothing in glassfish error log, nothing on firebug too.
tested on:
- plugin version: nbpfcrudgen-0.15.2-7.3.1impl.nbm
- ubuntu 12.04 64 bits
- netbeans netbeans ide 7.3
- primefaces 3.5
- glassfish server open source edition 4.0
- mozilla firefox 22.0
- mysql 5.6.11
you can watch video of test:
download source code:
button:
p:commandbutton actionlistener="#{countrycontroller.savenew}" value="#{mybundle.save}" update="display,:countrylistform:datalist,:growl" oncomplete="handlesubmit(xhr,status,args,countrycreatedialog);"/> page create.xhtml (go inside template.xhtml pages, edit.xhtml list.xhtml view.xhtml):
<?xml version="1.0" encoding="utf-8" ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <ui:composition> <p:dialog id="countrycreatedlg" widgetvar="countrycreatedialog" modal="true" resizable="false" appendtobody="true" header="#{mybundle.createcountrytitle}"> <h:form id="countrycreateform"> <h:panelgroup id="display"> <p:panelgrid columns="2" rendered="#{countrycontroller.selected != null}"> <p:outputlabel value="#{mybundle.createcountrylabel_name}" for="name" /> <p:inputtext id="name" value="#{countrycontroller.selected.name}" title="#{mybundle.createcountrytitle_name}" required="true" requiredmessage="#{mybundle.createcountryrequiredmessage_name}"/> </p:panelgrid> <p:commandbutton actionlistener="#{countrycontroller.savenew}" value="#{mybundle.save}" update="display,:countrylistform:datalist,:growl" oncomplete="handlesubmit(xhr,status,args,countrycreatedialog);"/> <p:commandbutton value="#{mybundle.cancel}" onclick="countrycreatedialog.hide()"/> </h:panelgroup> </h:form> </p:dialog> </ui:composition> </html> entity:
@entity @table(name = "country") @xmlrootelement @namedqueries({ @namedquery(name = country.find_all, query = "select c country c"), @namedquery(name = country.find_by_id, query = "select c country c c.id = :id"), @namedquery(name = country.find_by_name, query = "select c country c c.name = :name")}) public class country implements serializable, comparable<country> { private static final long serialversionuid = 1l; public static final string find_all = "country.findall"; public static final string find_by_id = "country.findbyid"; public static final string find_by_name = "country.findbysubtag"; @id @generatedvalue(strategy = generationtype.table, generator = "seqcountry") @tablegenerator(name = "seqcountry", initialvalue = 10000) @basic(optional = false) @column(name = "id", unique = true, updatable = false) private long id; @basic(optional = false) @notnull @size(min = 1, max = 255) @column(name = "name", unique = true, updatable = false) private string name; ... abstractcontroller:
import org.primefaces.test.crud.bean.abstractfacade; import org.primefaces.test.crud.controller.util.jsfutil; import java.util.list; import java.util.logging.level; import java.util.logging.logger; import javax.faces.event.actionevent; import java.util.resourcebundle; import javax.ejb.ejbexception; /** * represents abstract shell of used jsf controller used in * ajax-enabled applications. no outcomes generated methods * since handling designed done inside 1 page. */ public abstract class abstractcontroller<t> { private abstractfacade<t> ejbfacade; private class<t> itemclass; private t selected; private list<t> items; private enum persistaction { create, delete, update } public abstractcontroller() { } public abstractcontroller(class<t> itemclass) { this.itemclass = itemclass; } protected abstractfacade<t> getfacade() { return ejbfacade; } protected void setfacade(abstractfacade<t> ejbfacade) { this.ejbfacade = ejbfacade; } public t getselected() { return selected; } public void setselected(t selected) { this.selected = selected; } protected void setembeddablekeys() { // nothing if entity not have embeddable key. } ; protected void initializeembeddablekey() { // nothing if entity not have embeddable key. } /** * returns items in list object * * @return */ public list<t> getitems() { if (items == null) { items = this.ejbfacade.findall(); } return items; } public void save(actionevent event) { string msg = resourcebundle.getbundle("/mybundle").getstring(itemclass.getsimplename() + "updated"); persist(persistaction.update, msg); } public void savenew(actionevent event) { string msg = resourcebundle.getbundle("/mybundle").getstring(itemclass.getsimplename() + "created"); persist(persistaction.create, msg); if (!isvalidationfailed()) { items = null; // invalidate list of items trigger re-query. } } public void delete(actionevent event) { string msg = resourcebundle.getbundle("/mybundle").getstring(itemclass.getsimplename() + "deleted"); persist(persistaction.delete, msg); if (!isvalidationfailed()) { selected = null; // remove selection items = null; // invalidate list of items trigger re-query. } } private void persist(persistaction persistaction, string successmessage) { if (selected != null) { this.setembeddablekeys(); try { if (persistaction != persistaction.delete) { this.ejbfacade.edit(selected); } else { this.ejbfacade.remove(selected); } jsfutil.addsuccessmessage(successmessage); } catch (ejbexception ex) { string msg = ""; throwable cause = jsfutil.getrootcause(ex.getcause()); if (cause != null) { msg = cause.getlocalizedmessage(); } if (msg.length() > 0) { jsfutil.adderrormessage(msg); } else { jsfutil.adderrormessage(ex, resourcebundle.getbundle("/mybundle").getstring("persistenceerroroccured")); } } catch (exception ex) { logger.getlogger(this.getclass().getname()).log(level.severe, null, ex); jsfutil.adderrormessage(ex, resourcebundle.getbundle("/mybundle").getstring("persistenceerroroccured")); } } } /** * creates new instance of underlying entity , assigns selected * property. * * @return */ public t preparecreate(actionevent event) { t newitem; try { newitem = itemclass.newinstance(); this.selected = newitem; initializeembeddablekey(); return newitem; } catch (instantiationexception ex) { logger.getlogger(this.getclass().getname()).log(level.severe, null, ex); } catch (illegalaccessexception ex) { logger.getlogger(this.getclass().getname()).log(level.severe, null, ex); } return null; } public boolean isvalidationfailed() { return jsfutil.isvalidationfailed(); } }
https://sourceforge.net/p/nbpfcrudgen/tickets/14/
this seems caused changes in jsf 2.1 2.2 default glassfish 4. registering , using downloaded jsf 2.1 version in new project glassfish 4 not work. please consider crud generator broken glassfish 4 , jsf 2.2. may register previous version glassfish (3.1.2 tested work).
temporary solution:
only works classic option: (tested on)
glassfish 4 + jsf 2.2 + primefaces-4.0-20130711.071416-4.jar -> ok, except sortby , filterby glassfish 4 + jsf 2.2 + primefaces 3.5 -> ok glassfish 3.1.2 + jsf 2.1 + primefaces 3.5 -> ok glassfish 3.1.2 + jsf 2.1 + primefaces-4.0-20130711.071416-4.jar -> ok, except sortby , filterby
with primefaces 3.x: sortby="#{item.id}" filterby="#{item.id}" primefaces 4.x: can replace on template sortby="id" filterby="id"
Comments
Post a Comment