a4j:commandLink not work at first time - jsf-2

I hava a rich:tabPanel where i can add and remove tab dynamically
<rich:tabPanel id="tabsPanel" switchType="client" activeItem="#{tabsBean.activeTab}" itemChangeListener="#{tabsBean.tabChange()}" >
<c:forEach var="tab" items="#{tabsBean.tabs}" >
<rich:tab name="#{tab.name}" onheaderclick="switchTab('#{tab.name}');" >
<f:facet name="header">
<h:panelGrid columns="2">
<h:outputText value="#{tab.name}" />
<h:graphicImage value="#{pathImmagini.pathImmagineElimina}"
style="width:12px; height:12px;"
onclick="myFunc('#{tab.name}'); Event.stop(event);"/>
</h:panelGrid>
</f:facet>
<h:form id="#{tab.name}" >
<ui:include src="#{tab.pathComponent}" />
</h:form>
</rich:tab>
</c:forEach>
</rich:tabPanel>
where each tab has a its component *.xhtml (tab.pathComponent) , within of this components i have many a4j:commandlink that not works at first time.
this is one of my components (tab.pathComponent)
<rich:toolbar height="30" >
<a4j:commandLink action="#{tab.setNewObject('Nuovo Cliente')}" render="pannelloDatiCliente" execute="#this" >
<h:graphicImage value="#{pathImmagini.pathImmagineAggiungiSoggetto}"/>
</a4j:commandLink>
</rich:toolbar>
How i can do?

can you give bit more information regarding your xhtml. normally second click problem happens because of partial rendereing of page or UI. Can't tell the problem only with this part of code.

Related

primefaces dialog box and datatable checkbox selection

I want to display the selected rows of a table in a dialog box but I have an empty dialog box even if I check one or more line nothing is displayed .. I realy don't know what is the cause of my problem .. I hope there will be someone who can help me (I m a beginner in jsf2 and I just discovered primefaces I really want help thanks soo much in advance ) this is my jsf :
<p:outputLabel for="product" value="" />
<p:dataTable id="product" var="ligne" value="#{productBean.myProducts}" selection="#{productBean.selectedProducts}" style="margin-bottom:0" rowKey="#{productBean.id}">
<p:column selectionMode="multiple" style="width:16px;text-align:center"/>
<p:column headerText="Code">
<h:outputText value="#{ligne.code}" />
</p:column>
<p:column headerText="designation" >
<h:outputText value="#{ligne.title}" />
</p:column>
<f:facet name="footer">
<p:commandButton process="product" update=":form:multiProductDetail" icon="ui-icon-search" value="View" oncomplete="PF('multiProductDialog').show()" />
</f:facet>
</p:dataTable>
<p:dialog header="Products" widgetVar="multiProductDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false" width="200">
<p:outputPanel id="multiProductDetail" style="text-align:center;">
<ui:repeat value="#{prodBean.selectedProducts}" var="ligne">
<h:outputText value="#{ligne.code} -- #{ligne.title}" style="display:block"/>
</ui:repeat>
</p:outputPanel>
Did you put a
h:form
inside this page
Is there data inside selection="#{productBean.selectedProducts}" .Can you a debug point there and see or put some sysouts in the getters and setters of selectedProducts.
Can you share your product code and check if selectedProducts is null or not
system.out.println("products"+selectedProducts.get(0))
best
vj

Close tab dynamically not work rich:tabPanel

I have a rich:tabPanel where add tabs dinamically
<c:forEach var="tab" items="#{tabsBean.tabs}" >
<rich:tab name="#{tab.name}" >
<h:form id="#{tab.name}" >
<f:facet name="header">
<h:outputText value="#{tab.name}" />
<a4j:commandLink value="X" action="#{tabsBean.removeTab(tab)}" />
</f:facet>
<ui:include src="#{tab.path}" />
</h:form>
</rich:tab>
</c:forEach>
The troubles are
command link (X) is not show and when i close the tab i would open the #perv tab
How can i do?
f:facet name="header" must be a direct child of rich:tab (in your code it is a facet of h:form, but h:form does not support such facet, so it is not shown).
Note also if you are using RichFaces 4.x then you can not have form elements inside individual tabs, it is not supported yet, refer to:
https://issues.jboss.org/browse/RF-11306

How to use <h:form> in <rich:tabPanel>

I'm developing my first JSF2 + Richfaces application and now I have this problem.
I have the following rich:tabPanel to which add and remove dynamically tab.
<h:form>
<rich:tabPanel id="tabsPanel" switchType="ajax" activeItem="#{tabsBean.activeTab}" >
<c:forEach var="tab" items="#{tabsBean.tabs}" styleClass="myRightPanel">
<rich:tab name="#{tab.name}" styleClass="myTab" >
<h:form id="#{tab.name}" >
<ui:include src="#{tab.pathDaIncludere}" />
</h:form>
</rich:tab>
</c:forEach>
</rich:tabPanel>
</h:form>
but to run I must add a <h:form> around each <rich:tab> otherwise the actions in the tabs will not work.
Is correct insert <h:form> in each tab?

PrimeFaces dialog not working in Chrome browser

As you can see I am trying to display a dialog box on click on the command link, the dialog is displayed in IE and Firefox, but not in Google Chrome v23, please suggest.
<h:form id="myForm">
<p:tabView id="tabView">
<p:tab id="tab1" title="Tab 1">
<h:panelGrid columns="1" cellpadding="10">
<h:dataTable value="#{testBean.dataList}" var="data">
<h:column>
<h:outputText value="#{data}" />
</h:column>
<h:column>
<p:commandLink action="#{testBean.loadCommentHistory(data)}"
update=":myForm:tabView:dialog" oncomplete="dlg.show()">
<h:graphicImage url="resources/theme1/images/comments.gif"
styleClass="basicImageStyle" />
</p:commandLink>
</h:column>
</h:dataTable>
<p:dialog id="dialog" header="Dynamic Dialog" widgetVar="dlg">
<h:outputText value="#{testBean.commentHistory}" />
</p:dialog>
</h:panelGrid>
</p:tab>
</p:tabView>
</h:form>
When you update the dialog the dialog is reset to the default state which is hidden. If you call dialog.show() and update the dialog the dialog is hidden again. Chrome (being probably faster than IE or FireFox) seems to handle this differently. A solution would be to wrap the content of the dialog in a container and update the container.
<p:commandLink action="#{testBean.loadCommentHistory(data)}"
update=":myForm:tabView:dialog-content" oncomplete="dlg.show()">
<h:graphicImage url="resources/theme1/images/comments.gif"
styleClass="basicImageStyle" />
</p:commandLink>
<p:dialog id="dialog" header="Dynamic Dialog" widgetVar="dlg">
<p:outputPanel id="dialog-content">
<h:outputText value="#{testBean.commentHistory}" />
</p:outputPanel>
</p:dialog>
Try to encapsulate the page in a f:view tag if you haven't already. There is some problem when it is not present with Chrome and Safari. See http://primefaces.org/faq.html question 3
<html xmnls=... >
<f:view contentType="text/html">
<h:head>
....
</h:head>
<h:body>
....
</h:body>
</f:view>
</html>

Left Layout disappears whenever datatable is added within the center Pane of primeFaces Layout

Im using Jsf 2.0 and primefaces exstensions component pe:layout to create a page with left navigation menu bar ,bottom footer and center pane for content everthing works fine but when ever i add primefaces datatable (p:datatable) in the center pane the header and footer layouts are preserved but the left pane disappears and the center pane occupies the entire page. I tried setting width and height of the datatable but nothing seems to work. The page displays correctly without datatable. Any help would be greatly appreciated.
Please find below the code with datatable:
<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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
<ui:composition template="/templates/showcaseLayout.xhtml">
<ui:define name="centerContent">
<f:facet name="header">
<h:outputText value="Jan Sampark"/>
</f:facet>
<h:panelGroup layout="block" styleClass="centerContent">
Welcome to the Menu Page.
<p:growl id="messages" showDetail="true"/>
</h:panelGroup>
<p:tabView id="tabView">
<p:tab id="tab1" title="Godfather Part I">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage id="tab1Img" value="/images/godfather/godfather1.jpg" />
<h:outputText id="tab1Text"
value="The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business. T
hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect,
but given to ruthless violence whenever anything stands against the good of the family." />
</h:panelGrid>
</p:tab>
<p:tab id="tab2" title="Godfather Part II">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage id="tab2Img" value="/images/godfather/godfather2.jpg" />
<h:outputText id="tab2Text" value="Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, The_Godfather, parallels the young Vito Corleone's rise with his son Michael's spiritual fall, deepening The_Godfather's depiction of the dark side of the American dream.
In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy,
killing the local Black Hand Fanucci after he demands his customary cut of the tyro's business. With Fanucci gone, Vito's communal stature grows."/>
</h:panelGrid>
</p:tab>
<p:tab id="tab3" title="Godfather Part III">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage id="tab3Img" value="/images/godfather/godfather3.jpg" />
<h:outputText id="tab3Text" value="After a break of more than 15 years, director Francis Ford Coppola and writer Mario Puzo returned to the well for this third and final story of the fictional Corleone crime family.
Two decades have passed, and crime kingpin Michael Corleone, now divorced from his wife Kay has nearly succeeded in keeping his promise that his family would one day be completely legitimate."/>
</h:panelGrid>
</p:tab>
</p:tabView>
<h:panelGroup layout="block" styleClass="centerContent">
<p:dataTable var="car" value="#{tableBean.carsSmall}" id="carList" editable="true" style="table-layout: fixed"
scrollable="true" scrollHeight="250" scrollWidth="300">
<f:facet name="header">
In-Cell Editing
</f:facet>
<!-- <p:ajax event="rowEdit" listener="#{tableBean.onEdit}" update=":form:messages" /> -->
<!-- <p:ajax event="rowEditCancel" listener="#{tableBean.onCancel}" update=":form:messages" /> -->
<p:column headerText="Model" >
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.model}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{car.model}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Manufacturer">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.manufacturer}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{car.manufacturer}" >
<f:selectItems value="#{tableBean.manufacturers}"
var="man"
itemLabel="#{man}"
itemValue="#{man}" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Color">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.color}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{car.color}" >
<f:selectItems value="#{tableBean.colors}"
var="color"
itemLabel="#{color}"
itemValue="#{color}" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Options">
<p:rowEditor />
</p:column>
</p:dataTable>
</h:panelGroup>
</ui:define>
<ui:define name="docuTable">
<ui:include src="/sections/shared/documentation.xhtml">
<ui:param name="tagName" value="timeline"/>
</ui:include>
</ui:define>
</ui:composition>
</html>

Resources