I have two dataTables, one nest anther. The code as below :
<h:dataTable value="#{allUserBean.userList}" var="pmUsers">
<h:column headerClass="tableHeader column8Header">
<f:facet name="header">
<h:commandLink actionListener="#{allUser.sortByEmpNo}" immediate="true">
<h:panelGrid columns="2" columnClasses="colSortText,colSortImg">
<h:outputText value="Emp No." />
<h:panelGrid rendered="#{allUserBean.sortType == 0}">
<h:graphicImage url="/images/sortup.gif" rendered="#{allUserBean.up}" />
<h:graphicImage url="/images/sortdown.gif" rendered="#{!allUserBean.up}" />
</h:panelGrid>
</h:panelGrid>
</h:commandLink>
</f:facet>
<h:outputText value="#{pmUsers.employeeNo}" />
</h:column>
<h:dataTable var="iterm" value="#{pmUsers.userMultyResumeList}"">
<h:outputText value="#{iterm}" />
</h:dataTable> `
The show successful, but the other dataTable of userMultyResumeList can't be showed.
I used the testing code , it is false. so the value is not null, i don't know why
The userList code as :
private List<User> userList;
userList = userService.getUsersByPMGroupNotIncluded("", groupIds);
<h:dataTable var="iterm" value="#{pmUsers.userMultyResumeList}"">
Please repalce this line with this
<h:dataTable var="iterm" value="#{pmUsers.userMultyResumeList}">
Related
I have a primefaces datatable which displays a list of cars. One of the columns of the datatable has a command button which when clicked opens a dialog box which displays information about the selected car. Everything works as expected until I default filter the datatable and select the command button of a filtered row. The details of the car is null in this case. How can I get the value (car object) of the selected row after filtering?
<h:form id="carView">
<h:panelGrid id="carPanelGroup" style="width:100%" styleClass="tblNowrap100pct">
`<p:dataTable value="#{carBean.carList}" var="car" id="carTbl" stripedRows="true" rendered="#{not empty carBean.carList}" showGridlines="true" styleClass="tblNowrap100pct" filteredValue="#{carBean.filteredValues}" rowKey="#{car.carId}">
<p:column headerText="Car Name" sortBy="#{car.carName}" filterBy="#{car.carName}" filterMatchMode="contains" >
<f:facet name="header">
<h:outputText value="Car Name" />
</f:facet>
<h:outputText value="#{car.carName}" />
</p:column>
<p:column headerText="Make" sortBy="#{car.make}" filterBy="#{car.make}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="Make" />
</f:facet>
<h:outputText value="#{car.make}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Car Download" />
</f:facet>
<p:commandButton action="#{carBean.selectCar}" value="Download" styleClass="linkButton" process="#this" oncomplete="PF('carDownloadpanel').show();" update="#all">
<f:setPropertyActionListener value="#{car}" target="#{carBean.carDto}"/>
</p:commandButton>
</p:column>`
</p:dataTable>
</p:panelGrid>
</h:form>
<!-- ******** pop up -->
<p:outputPanel id = "downloadOutputPanel">
<p:dialog header="#{carBean.carDto.carName}" widgetVar="carDownloadpanel" width="500" height="400" id="dialogDetails" modal="true">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="#{carBean.carDto.carName}" />
</h:panelGroup>
</f:facet>
<h:form id="carDetailView">
<p:panel>
<p:panelGrid id="carDetails" columns="2" styleClass="summaryTable"
columnClasses="colLabel, colNormalInputArea" rendered="#{not empty firmBean.firmDto}">
<h:outputText value="Car Name:" />
<h:outputText value="#{carBean.carDto.carName}" />
<h:outputText value="Firm Id:" />
<h:outputText value="#{carBean.carDto.carId}" />
</p:panelGrid>
</p:panel>
</h:form>
<h:form id="iwaInfo">
<h:panelGrid id="carReportInput" columns="2" styleClass="summaryTable" columnClasses="colLabel, colNormalInputArea">
<p:commandLink value="Download" id="downloadBtn"
action="#{carBean.downloadCar}" onclick="PF('carDownloadpanel').hide();">
</p:commandLink>
<p:commandLink value="Cancel" id="cancelBtn"
oncomplete="PF('carDownloadpanel').hide();" update=":carView:carPanelGroup" process="#parent"/>
</h:panelGrid>
</h:form>
</p:dialog>
</p:outputPanel>
Java method :
public String selectCar(){
if (this.carDto != null) {
carId = this.carDto.getCarId();
instanceId = this.carDto.getInstanceId();
if (carId!=null&&instanceId!=null){
CarDto dto = new CarDto();
List<CarDto> sLst = carService.searchCar(Long.parseLong(carId), Long.parseLong(instanceId));
if (sLst!=null&&sLst.size()>0){
dto= sLst.get(0);
}
setCarDto(dto);
}
}
return "";
}
Hello Guys i need your help as usual
Jsf h:dataTable - not refreshing after deleting row.
Not until i have to restart the programm.
what can i do please to resolve this problem?
Thanks John.
ManagedBean
public List<Customer> getCustomerList() {
if (customerList == null) {
customerList = new ArrayList<Customer>(bookstoreManager.getAllCustomers());
for (Customer cus : customerList) {
System.out.println("Hello" + cus.getFirstName() + "......." + cus.getLastName());
}
}
return customerList;
}
Business Logik
public List<Customer> getAllCustomers() {
TypedQuery<Customer> query = em.createQuery("Select c from Customer c", Customer.class);
return query.getResultList();
}
XHTML Code
<ui:define name="content">
<h:body>
<h:outputStylesheet name="css/style.css" />
<h:form id="form">
<h:dataTable var="cus" cellpadding="5" cellspacing="5" border="1"
width="400" styleClass="customerList"
value="#{customerBean.getCustomerList()}">
<h:column>
<f:facet name="header">
<h:outputText value="#{texts.firstName}" />
</f:facet>
<h:outputText value="#{cus.firstName}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{ texts.lastName}" />
</f:facet>
<h:outputText value="#{cus.lastName}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{texts.address}" />
</f:facet>
<h:outputText value="#{cus.address}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{texts.creditCard}" />
</f:facet>
<h:outputText value="#{cus.creditCard}" />
</h:column>
<h:column>
<h:commandLink action="#{customerBean.selectCustomer(cus)}"
value="Edit" />
</h:column>
<h:column headerText="Delete">
<h:commandLink value="#{texts.delete}"
action="#{customerBean.deleteCustomer(cus)}" />
</h:column>
</h:dataTable>
</h:form>
</h:body>
</ui:define>
I'm trying to pass a parameter between two xhtml, I have the next code for the first xhtm
<h:dataTable value="#{ofertaController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListOfertaTitle_idoferta}"/>
</f:facet>
<h:outputText value="#{item.idoferta}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListOfertaTitle_fechaInicio}"/>
</f:facet>
<h:outputText value="#{item.fechaInicio}">
<f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListOfertaTitle_fechaFin}"/>
</f:facet>
<h:outputText value="#{item.fechaFin}">
<f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListOfertaTitle_descripcion}"/>
</f:facet>
<h:outputText value="#{item.descripcion}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListOfertaTitle_precioInicial}"/>
</f:facet>
<h:outputText value="#{item.precioInicial}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListOfertaTitle_precioFinal}"/>
</f:facet>
<h:outputText value="#{item.precioFinal}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListOfertaTitle_negocioCif}"/>
</f:facet>
<h:outputText value="#{item.negocioCif}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value=" "/>
</f:facet>
<h:commandLink action="#{ofertaController.prepareView}" value="#{bundle.ListOfertaViewLink}"/>
<h:outputText value=" "/>
<h:commandLink action="#{ofertaController.prepareEdit}" value="#{bundle.ListOfertaEditLink}"/>
<h:outputText value=" "/>
<h:commandLink action="#{ofertaController.destroy}" value="#{bundle.ListOfertaDestroyLink}"/>
<h:link outcome="/cupon/compra" value="Comprar">
<f:param name="idOferta" value="#{item.idoferta}" />
</h:link>
</h:column>
</h:dataTable>
As you can see I have a:
<h:link outcome="/cupon/compra" value="Comprar">
<f:param name="idOferta" value="#{item.idoferta}" />
</h:link>
And I get the next url:
http://localhost:8080/agrupados/faces/cupon/compra.xhtml?idOferta=1
This idOferta=1 I want to use it in a Managed bean but always, it appears as null, why?. The xhtml which I linked before is this one:
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="#{bundle.CreateCuponLabel_email}" for="email" />
<h:inputText id="email" value="#{cuponController.selected.email}" title="#{bundle.CreateCuponTitle_email}" required="true" requiredMessage="#{bundle.CreateCuponRequiredMessage_email}"/>
</h:panelGrid>
<br />
<h:commandLink action="#{cuponController.create}" value="#{bundle.CreateCuponSaveLink}" />
<br />
<br />
<h:commandLink action="#{cuponController.prepareList}" value="#{bundle.CreateCuponShowAllLink}" immediate="true"/>
<br />
<br />
<h:link outcome="/index" value="#{bundle.CreateCuponIndexLink}"/>
<br/>
<h:commandButton id="compra" value="COMPRAR" action="#{compra.addCompra}" />
</h:form>
And the ManagedBean is this one where is the addCompra:
#ManagedBean(name="compra")
#RequestScoped
public class Compra {
#EJB
private NegocioFacade negocioFacade;
#EJB
private OfertaFacade ofertaFacade;
#ManagedProperty(value = "#{param.idOferta}")
private String idOferta;
//(String)
public Compra() {
}
public void addCompra(){
System.out.println(idOferta);
FacesContext fc=FacesContext.getCurrentInstance();
String idoferta=ofer(fc);
System.out.println(idoferta);
}
public String ofer(FacesContext fc){
Map<String,String> params = fc.getExternalContext().getRequestParameterMap();
return params.get("idOferta");
}
}
What can I do?, how can I get this idOferta=1?. Thanks so much for all guys
you can use f:viewParam like this:
<f:metadata>
<f:viewParam name="idOferta" value="#{compra.idOferta}" />
</f:metadata>
just don't forget to add the getter-setter methods for idOferta to class compra, and remove the #ManagedProperty annotation.
So I have the following table:
<h:dataTable id="shoppingCartTable" value="#{cartBean.shoppingCartList}" var="shoppingCartItem" width="100%" >
<h:column>
<f:facet name="header">
<h:outputText value="Item" />
</f:facet>
<h:commandLink value="#{shoppingCartItem.name}">
</h:commandLink><br/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Quantity" />
</f:facet>
<h:inputText id="quantity" value="#{shoppingCartItem.quantity}" size = "2" /><br/>
</h:column>
</h:dataTable>
With the following commandButton
<p:commandButton
value="Submit"
>
<f:ajax event="click"
execute="shoppingCartTable"
render="#all" />
</p:commandButton>
Now there is a lot of other stuff on the page and all I want to do is update the Quantity values of the shopping cart items but this does not seem to be working. Am I doing something wrong?
Try to replace f:ajax with p:commandButton attributes:
<p:commandButton value="Submit" update="#all" process="shoppingCartTable"/>
I've ArrayList Collection carry the values properly , but the problem when i rendered it in h:dataTable tag the rows become all same value like in the picture.
<h:dataTable value="#{contactController.contacts }" var="contact"
rowClasses="oddRow, evenRow" styleClass="contactTable"
headerClass="headerTable" columnClasses="normal,centered"
rendered="#{not empty contactController.contacts }">
<h:column>
<f:facet name="header">
<h:column>
<h:outputText value="Name" />
</h:column>
</f:facet>
<h:outputText
value="#{contactController.contact.firstName }#{ contactController.contact.secondName }" />
</h:column>
<h:column>
<f:facet name="header">
<h:column>
<h:outputText value="Action" />
</h:column>
</f:facet>
<h:panelGrid columns="2">
<h:commandLink value="remove"
action="#{contactController.remove }">
<f:setPropertyActionListener value="#{contact }"
target="#{contactController.selectedContact }" />
</h:commandLink>
<h:commandLink value="edit" action="#{contactController.read}">
<f:setPropertyActionListener value="#{contact }"
target="#{contactController.selectedContact }" />
</h:commandLink>
</h:panelGrid>
</h:column>
</h:dataTable>
Any suggestion? .
I think there are two problems with your code.
First you don't need the bean's name in your columns. Simply use the content of the var attribute (in your case "contact" and not "contactController.contact")
Second: The h:column inside f:facet is not correct. Put the h:outputText directly into f:facet.
Change your first column this way:
<h:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{contact.firstName} #{contact.secondName }" />
</h:column>