sidenote: works command-buttons.
what have:
a simple form name , address customer entered. in data-table below, each row contained (in working version) following fields:
- name of customer
- a command-button redirects page , shows customers orders (this worked using
<p: commandbutton immediate="true">) - another command-button displayed past orders.
- another command-button responsible updating customer-data.
since didn't want have 3 command-buttons in each row decided use split-button.
problem:
<p:splitbutton immediate="true"> the form asks me fill missing data (name , address) set required="true.
question: far understand attribute immediate="true used overcome issue. missing ?
code:
<h:form> <p:growl id="growl" sticky="false" life="3500" showdetail="false"/> <h:panelgrid id="customer_grid" columns="2" cellspacing="1" cellpadding="5"> <h:outputlabel id="label" for="name" value="kunde:" style="font-weight:bold"/> <p:inputtext id="name" value="#{customercontroller.customer.name}" required="true" requiredmessage="name eingeben!"/> <h:outputlabel for="address" value="adresse:" style="font-weight: bold" /> <p:inputtext id="address" value ="#{customercontroller.customer.address}" required="true" requiredmessage="adresse eingeben!"/> <p:commandbutton action = "#{customercontroller.createcustomer}" value="speichern" style="margin-right:10px" actionlistener="#{growlcontroller.savemessage}" ajax="true" onclick="pf('blockuiwidget').block()" oncomplete="pf('blockuiwidget').unblock()" styleclass="save-button"/> <p:commandbutton onclick="history.back(); return false;" value="abbrechen" ajax="true"/> <pe:blockui widgetvar="blockuiwidget"> <h:panelgrid columns="2"> <p:graphicimage id="loader" name="images/ajax-loader.gif" style="margin-right: 12px; vertical-align: middle;" rendered="true"/> <h:outputtext value="please wait..." style="white-space: nowrap;"/> </h:panelgrid> </pe:blockui> </h:panelgrid> <br/> <br/> <p:datatable var="customer" value="#{customercontroller.allcustomers}" resizablecolumns="true" tablestyle="width: auto" rendered="#{not empty customercontroller.allcustomers}"> <p:column headertext="customer" style="width: 300px"> <h:outputtext value="#{customer.name}" /> </p:column> <p:column> <p:splitbutton value="current order" action="#{usercontroller.setup(customer, 'lastorder')}" immediate="true"> <p:menuitem value="old orders" action="#{usercontroller.setup(customer, 'oldorders')}" immediate="true"/> <p:menuitem value="edit" action="#{usercontroller.setup(customer, 'update')}" immediate="true"/> </p:splitbutton> </p:column> </p:datatable> edit:
according comment of balusc i've put 2 parts in separate forms. effect: message fill out above form not show up, redirect not happening either.
edit2:
the purpose of method usercontroller.setup(customer, 'string') inject customer represented each row. string returned redirecting purposes set in faces-config.xml , said: works when use command-buttons instead.
code:
@named @sessionscoped public class usercontroller implements serializable{ @inject private customer customer; @ejb private customerservice customerservice; public usercontroller(){ } public list<item> getitems(){ return customerservice.getitems(customer); } public ordery getcurrentorder(){ return customerservice.getcurrentorder(customer); } public customer getcustomer() { return customer; } public void setcustomer(customer customer) { this.customer = customer; } public customerservice getcustomerservice() { return customerservice; } public void setcustomerservice(customerservice customerservice) { this.customerservice = customerservice; } public string setup(customer customer, string nav){ this.customer = customer; return nav; } public void update(){ customerservice.update(customer); } }
Comments
Post a Comment