Primefaces Datatable filtering and pagination issue - jsf-2

I am using the JSF 2.0 and primefaces 3.5. the problem i am facing is i have created a datatable on a page .. every things works fine along with pagination and filtering, but when i include the same page into the template ... the pagination and filtering stop working.. any idea regarding this
the code is
<h:form id="form">
<p:dataTable var="row" rowKey="row.attackID"
value="#{attackBean.list}" id="tableAttack" paginator="true"
rows="10" selection="#{attackBean.selectedAttack}"
filteredValue="#{attackBean.filteredAttack}"
rowsPerPageTemplate="5,10,15" selectionMode="single">
<p:ajax event="rowSelect" update=":centerForm:form:display"
oncomplete="dlg.show()" />
<p:column headerText="Attack-ID" filterBy="#{row.attackID}">
<h:outputText value="#{row.attackID}" />
</p:column>
<p:column headerText="Action Name" filterBy="#{row.attackName}">
<h:outputText value="#{row.attackName}" />
</p:column>
<p:column headerText="Defended User" filterBy="#{row.userID}">
<h:outputText value="#{row.userID}" />
</p:column>
<p:column headerText="Action Taken">
<h:outputText value="#{row.actionTaken}" />
</p:column>
<p:column headerText="Attack Time">
<h:outputText value="#{row.attackTime}" />
</p:column>
</p:dataTable>
<p:dialog id="tDialog" header="Threat info" widgetVar="dlg"
modal="true" height="250" width="300" showEffect="explode"
hideEffect="bounce">
<h:panelGrid id="display" columns="1" cellpadding="4">
<h:outputText value="Attack ID: #{attackBean.selectedAttack.attackID} " />
<h:outputText value="Description: #{attackBean.selectedAttack.userID}" />
<h:outputText
value="Action Taken: #{attackBean.selectedAttack.actionTaken}" />
</h:panelGrid>
</p:dialog>
</h:form>
here is the main templete code
<h:body style="">
<div id="page" >
<h:panelGroup id="mainPanel">
<div id="left" class="bar">
<ui:insert name="left">
<ui:include src="commonLeft.xhtml" />
</ui:insert>
</div>
<div id="center">
<div id="hDiv">
<ui:insert name="left">
<ui:include src="commonHeader.xhtml" />
</ui:insert>
</div>
<div id="cDiv">
<h:form id="centerForm">
<h:panelGroup id="centerPanel" render="mainPanel">
<ui:include src="#{browse.url}" />
</h:panelGroup>
</h:form>
</div>
</div>
<div id="right" >
<ui:insert name="right">
<ui:include src="commonFooter.xhtml" />
</ui:insert>
</div>
</h:panelGroup>
</div>
</h:body>

I assume you are including your template in this section:
<h:form id="centerForm">
<h:panelGroup id="centerPanel" render="mainPanel">
<ui:include src="#{browse.url}" />
</h:panelGroup>
</h:form>
If that's the case, then you have a problem of nested forms. That is not allowed and the inner form is getting removed from the HTML code (you can see that in the source code in the browser). You should not impose the form in the parent template, and let the children create the forms they are going to use.

Related

syntaxhighlighter CSS not working

I add the syntaxhighlighter library to my project in order to view XML files.
For some reason when using the syntaxhighlighter outside the dialog then I can see the CSS style but not within the dialog.
This is not working:
<p:commandButton id="button"
value="View"
oncomplete="hdsWidgetVar.show()"
update=":mainForm:hdsForm"
disabled="#{object.disableButton}"
icon="ui-icon-search"
style="float: right"/>
</p:row>
</p:panelGrid>
<f:verbatim><br/></f:verbatim>
<p:dialog id="hdsDialog"
widgetVar="hdsWidgetVar"
header="HDS"
width="800"
showEffect="clip"
hideEffect="clip"
position="left"
appendTo="#(body)"
dynamic="true" >
<h:form id="hdsForm">
<pre class="brush: xml">
<h:outputText value="#{object.selectedObjectSet.hds}" escape="true" />
</pre>
</h:form>
</p:dialog>
I cannot use dynamic="false" since I need to refresh the dialog text when user press the button.
Is there any workaround ?
Thanks
are you nesting forms?? using appendTo is a workaround to avoid nesting. i would not use it, if i can.
this should work, if you can separate forms:
<h:form>
<p:panelGrid>
<p:row>
<p:commandButton id="button"
value="View"
oncomplete="hdsWidgetVar.show()"
process="#form"
update="#this :hdsForm"
disabled="#{object.disableButton}"
icon="ui-icon-search"
style="float: right"/>
</p:row>
</p:panelGrid>
</h:form>
<f:verbatim><br/></f:verbatim>
<p:dialog id="hdsDialog"
widgetVar="hdsWidgetVar"
header="HDS"
width="800"
showEffect="clip"
hideEffect="clip"
position="left"
appendTo="#(body)"
dynamic="true" >
<h:form id="hdsForm">
<pre class="brush: xml">
<h:outputText value="#{object.selectedObjectSet.hds}" escape="true" />
</pre>
</h:form>
</p:dialog>
if you can't, this should go:
<h:form>
<p:panelGrid id="panelGrid">
<p:row>
<p:commandButton id="button"
value="View"
oncomplete="hdsWidgetVar.show()"
process="panelGrid"
update="#this hdsForm"
disabled="#{object.disableButton}"
icon="ui-icon-search"
style="float: right"/>
</p:row>
</p:panelGrid>
<f:verbatim><br/></f:verbatim>
<p:dialog id="hdsDialog"
widgetVar="hdsWidgetVar"
header="HDS"
width="800"
showEffect="clip"
hideEffect="clip"
position="left">
<h:panelGroup id="hdsForm">
<pre class="brush: xml">
<h:outputText value="#{object.selectedObjectSet.hds}" escape="true" />
</pre>
</h:panelGroup>
</p:dialog>
</h:form>
but maybe it's not a problem related to dynamic. more likely it's lib-to-work-with-ajax related.
this will solve the problem:
<p:commandButton id="button"
value="View"
oncomplete="SyntaxHighlighter.highlight();udmWidgetVar.show();"
process="#form"
update="#this :hdsForm"
disabled="#{object.disableButton}"
icon="ui-icon-search"
style="float: right"/>
and:
<p:dialog id="hdsDialog"
widgetVar="hdsWidgetVar"
header="HDS"
width="800"
showEffect="clip"
hideEffect="clip"
position="left"
appendTo="#(body)"
dynamic="false">
<h:panelGroup id="hdsForm" >
<pre class="brush: xml">
<h:outputText value="#{object.selectedObjectSet.hds}" escape="true" />
</pre>
</h:panelGroup>

How to process primefaces dialog

I have a primefaces dialog and what I want to do is process inputtext before commandbutton action starts. Inside myController.sendToPostBox method, myController.rejectionReason string returns null. Here is my view code.When I remove process attribute, commandbutton doesn't works.
<h:form>
....
<p:dialog id="myPanel"
widgetVar="myPanelId"
resizable="true"
appendToBody="true"
draggable="true"
height="200"
width="300">
<p:panelGrid id="myPanelGridId" style="width: 250px;" styleClass="panelGridWithoutBorder">
<p:row>
<p:column colspan="2">
<p:inputTextarea style="width: 250px;" value="#{myController.rejectionReason}"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:commandButton value="Save"
oncomplete="if (!args.validationFailed) myPanel.hide();"
process="myPanelId"
action="#{myController.sendToPostBox()}"/>
</p:column>
<p:column>
<p:commandButton value="Close" />
</p:column>
</p:row>
</p:panelGrid>
</p:dialog>
</h:form>
Just place the <h:form> inside the dialog (instead dialog inside the <h:form>)
Explanation:
When you use appendToBody="true" you dialog is being transferred outside of the form that wraps it to the body of the generated html , and since there is no form inside the dialog you can't really submit it.
Also take a look at this thread: Proper Construct for Primefaces Dialog
You need something like this:
<h:form id="formDialog">
<p:commandButton id="basic" value="Basic Dialog" onclick="PF('dlg1').show();" type="button" />
</h:form>
<p:dialog id="basicDialog" header="Basic Dialog" widgetVar="dlg1">
<h:form id="formUser">
<h:panelGrid id="grid" columns="2">
<h:outputLabel value="Username:" />
<p:inputText id="user" value="#{user.name}" />
<h:outputLabel value="Password:" />
<p:inputText id="password" value="#{user.password}" />
<h:commandButton value="Login" id="btn" process="#formUser" actionListener="#{user.login}" />
</h:panelGrid>
</h:form>
</p:dialog>
"login" in the actionListener tag is a method in the User(bean) class, that needs the #ManagedBean annotations.

command button not invoking action on multiple tabs p:tabView

I am facing a problem in p:tabView with dynamic="true" which i am stuck in for days.
I have three tabs each having separate form and p:fileUpload with command button for submitting the form and upload file.
The problem is my first form or tab works fine but the other two are not working or firing command button action at all, instead ti refreshes the page. They are invoked only when second time form filled and button pressed.
And to add one thing more the fileUploadListeners even work fine in all these tabs but the command button wont work or fire action method for other two tabs(only the first time form filled and submitted after that works fine):
Is there something wrong with this primefaces tag(i m using latest version of primefaces 3.5 also) or i am mistaking or missing something?? any kind of guidance will be helpful.
Here is the page code which is included in another main page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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"
template="/MasterPage/Master.xhtml">
<ui:define name="Search">
<div class="searchBarDiv"></div>
<br class="clear" />
<div class="resultMainDiv" style="background-color: white;">
<p:layout style="width:1218px;height:558px;" id="layout">
<p:ajax event="toggle" />
<p:layoutUnit position="west" size="300" header="UPDATES"
resizable="true" collapsible="true" styleClass="sliderDiv"
style="color:pink;">
</p:layoutUnit>
<p:layoutUnit position="center" styleClass="resultDiv">
<div class="uploadDiv">
<p:tabView id="tabview" cache="false" dynamic="true">
<p:tab id="docTab" title="Document">
<h:form id="docf" >
<h:panelGrid id="grid" columns="1">
<h:panelGroup>
<h:outputLabel styleClass="advLabel"
for="mId" value="Title ">
</h:outputLabel><h:outputLabel style="color: red;">*</h:outputLabel>
<h:inputText id="mId"
styleClass="txtfield"
value="#{documentInsertController.documentTitle}">
</h:inputText>
</h:panelGroup>
<h:panelGroup>
<h:outputLabel class="advLabel">Dated </h:outputLabel>
<p:calendar styleClass="txtfield" id="dtxtOrginated"
mode="popup" navigator="true" yearRange="1900:2015"
pattern="dd-MMM-yyyy"
converter="CalendarDateStringConverter"
value="#{documentInsertController.documentOriginatedOn}" />
</h:panelGroup>
<h:panelGroup>
<h:outputLabel class="advLabel">KeyWord</h:outputLabel><h:outputLabel
style="color: red;"> *</h:outputLabel>
<h:inputText id="dtxtKeywordsList"
value="#{documentInsertController.documentKeywords}"
styleClass="txtfield" />
</h:panelGroup>
<h:panelGrid rendered="#{renderBean.viewLoad}">
<h:panelGroup> <h:outputLabel class="advLabel">Select Document</h:outputLabel><h:outputLabel
style="color: red;"> *</h:outputLabel>
<p:fileUpload id="fu" allowTypes="/(\.|\/)(DOC|DOCX|doc|docx|ppt|xls|xlsx|pdf)$/"
multiple="false" mode="advanced" sizeLimit="41949000" showButtons="false"
fileUploadListener="#{documentInsertController.uploadPListener}" label="Browse"
value="#{documentInsertController.file}" >
<h:message id="docMSG" for="fu"></h:message>
</p:fileUpload>
</h:panelGroup>
<h:panelGroup>
<p:commandButton id="DocUpoadLoad" styleClass="btn"
value="Load File For Preview" ajax="false"
action="#{documentInsertController.loadDocForPreview}"
style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold;width:170px; height:25px;">
</p:commandButton>
</h:panelGroup>
</h:panelGrid>
</h:panelGrid>
</h:form>
<p:commandButton id="DocUploadbtn" value="Upload"
action="#{documentInsertController.saveDocument}"
ajax="false"
style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold; ">
</p:commandButton>
</h:panelGrid>
</p:tab>
<p:tab id="imgTab" title="Image">
<h:form id="imagef" >
<h:panelGrid id="grid" columns="1">
<h:panelGroup> <h:outputLabel class="advLabel">Title </h:outputLabel> <h:outputLabel
style="color: red;"> *</h:outputLabel>
<h:inputText id="txtImgTitle"
value="#{mediaInsertController.mediaTitle}"
styleClass="txtfield" >
</h:inputText>
</h:panelGroup>
<h:panelGroup> <h:outputLabel class="advLabel">Taken Date</h:outputLabel>
<p:calendar styleClass="txtfield"
id="imgtxtOrginated" mode="popup" navigator="true"
yearRange="1900:2015" pattern="dd-MMM-yyyy"
converter="CalendarDateStringConverter"
value="#{mediaInsertController.mediaTakenOn}" />
</h:panelGroup>
<h:panelGroup> <h:outputLabel class="advLabel">Description</h:outputLabel>
<h:inputTextarea id="txtImgDescription"
value="#{mediaInsertController.mediaDescription}"
styleClass="txtImgDescription" /></h:panelGroup>
<h:panelGroup> <h:outputLabel class="advLabel">Select Image</h:outputLabel><h:outputLabel
style="color: red;"> *</h:outputLabel>
<p:fileUpload id="fuImage" allowTypes="/(\.|\/)(jpeg|jpg|png|bmp|gif|GIF|PNG)$/"
multiple="false" mode="advanced" sizeLimit="6291456" showButtons="false"
label="Browse" invalidSizeMessage="File exceeds limmit 6 MB "
value="#{mediaInsertController.file}" fileUploadListener="#{mediaInsertController.uploadPListener}" />
<h:message id="imgMSG" for="fuImage"></h:message>
</h:panelGroup>
<p:commandButton styleClass="btn" id="btnUploadImage_Click" ajax="false"
value="Upload" actionListener="#{mediaInsertController.saveImage}"
style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold; ">
</p:commandButton>
</h:panelGrid>
</h:form>
</p:tab>
<p:tab id="vidTab" title="Video">
<h:form id="videof" >
<h:panelGrid id="grid" columns="1">
<h:panelGroup>
<h:outputLabel class="advLabel">Title </h:outputLabel> <h:outputLabel
style="color: red;"> *</h:outputLabel>
<h:inputText id="vtxtTitle"
value="#{mediaInsertController.mediaTitle}"
styleClass="txtfield" maxlength="50" >
</h:inputText></h:panelGroup>
<h:panelGroup> <h:outputLabel class="advLabel">Taken Date</h:outputLabel>
<p:calendar styleClass="txtfield" id="vtxtOrginated"
mode="popup" navigator="true" yearRange="1900:2015"
pattern="dd-MMM-yyyy"
converter="CalendarDateStringConverter"
value="#{mediaInsertController.mediaTakenOn}" />
</h:panelGroup>
<h:panelGroup> <h:outputLabel for="txtVidDescription"
value="Description" styleClass="advLabel"></h:outputLabel>
<h:inputTextarea id="txtVidDescription"
value="#{mediaInsertController.mediaDescription}"
styleClass="txtUploading" style="height:40px" />
</h:panelGroup>
<h:panelGroup> <h:outputLabel class="advLabel">Select Video</h:outputLabel><h:outputLabel
style="color: red;"> *</h:outputLabel>
<p:fileUpload id="fuVideo" allowTypes="/(\.|\/)(mp4|flv|swf)$/" invalidFileMessage="Invalid file content"
multiple="false" mode="advanced" sizeLimit="629145699" showButtons="false" update="vidMSG"
fileUploadListener="#{mediaInsertController.uploadPListener}" label="Browse" invalidSizeMessage="Size exeeds limit 600MB"
value="#{mediaInsertController.file}" />
<h:message id="vidMSG" for="fuVideo"></h:message>
</h:panelGroup>
<p:commandButton styleClass="btn" id="btnUploadVideo_Click" ajax="false"
value="Upload" action="#{mediaInsertController.saveVideo}"
style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold; ">
</p:commandButton>
</h:panelGrid>
</h:form>
</p:tab>
</p:tabView>
</div>
</p:layoutUnit>
</p:layout>
<p:growl autoUpdate="true" sticky="true" id="uploadMSG"></p:growl>
</div>
</ui:define>
</ui:composition>
Your commandButton id="DocUploadbtn" is outside the h:form, that could be affecting things. There also seem to be three closing h:panelGrid tags around the same area; could it be malformed XHTML?

Primefaces3.5+JSF2.1.9 Request processing after Clicking link or Button twice

I am using Primefaces3.5 with Jsf2.1.9 i am getting a weired issue with
<p:commandButton>
as well as
<p:commandLink>
I have to press button as well as link more than one then JSF bean method is calling otherwise on Single click nothing Happening as i read some Stackoverflow Question this Issue relates to JSF but even using Primfaces3.5 with their Components i am getting this issue.Any one know How can i resolve this issue.
My JSF page
<ui:composition xmlns:jsp="http://java.sun.com/JSP/Page"
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:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
template="./../portfolio/PortfolioViewTemplate.xhtml">
<ui:define name="moduleContent">
<p:panel id="panel" header="Portfolio Transaction">
<p:messages id="msgs" />
<p:panelGrid id="addMoreTrans" columns="2" style="border-style:none;">
<f:facet name="header">
Add Trades
</f:facet>
<p:dataTable var="moreTrans"
value="#{portfolioTransactionBean.listOfTrasPanel}" style="border:none;" >
<p:column style="border:none;">
<p:panelGrid columns="7" id="transactionPanel1"
style="display: inline-block;border:none;">
<h:outputLabel for="tipsSuggestionBoxId" value="Company Name:*"></h:outputLabel>
<h:outputText value="Date:*" />
<h:outputText value="Type:*" />
<h:outputText value="Quantity:*" />
<h:outputText value="Price:*" />
<h:outputText value="Brokerage:" />
<h:outputText value="Notes:" />
<p:autoComplete id="tipsSuggestionBoxId"
completeMethod="#{applicationScopeBean.autoSelectCompany}"
value="#{portfolioTransactionBean.txnCurrentRecord.companyName}"
minChars="3" nothingLabel="No similar company found"
requestDelay="1" minQueryLength="3" required="true"
requiredMessage="Company Name Cannot be empty">
</p:autoComplete>
<p:calendar id="from_date1" size="10" required="true"
requiredMessage="Date Cannot be empty"
value="#{portfolioTransactionBean.txnCurrentRecord.umptTransDate}"
mode="popup" showOn="both" pattern="dd/MM/yyyy"
popupIconOnly="true" readonly="#{facesContext.renderResponse}"
navigator="true" showButtonPanel="true">
</p:calendar>
<p:selectOneMenu id="tranType"
value="#{portfolioTransactionBean.txnCurrentRecord.umptTransType}">
<f:selectItem itemLabel="Transaction Type" itemValue="" />
<f:selectItem itemLabel="Buy" itemValue="Buy" />
<f:selectItem itemLabel="Sell" itemValue="Sell" />
<f:selectItem itemLabel="Bonus" itemValue="Bonus" />
<f:selectItem itemLabel="Split" itemValue="Split" />
</p:selectOneMenu>
<p:spinner id="transQuntity1" required="true"
value="#{portfolioTransactionBean.txnCurrentRecord.umptQty}"
min="1" label="Quanity" size="5"
validatorMessage="Field Is mandatory" />
<p:spinner id="transPrice1" required="true" size="5"
value="#{portfolioTransactionBean.txnCurrentRecord.umptPrice}"
label="Price" validatorMessage="Field Is mandatory" />
<p:spinner id="brokerage1" size="5"
value="#{portfolioTransactionBean.txnCurrentRecord.umptBrokerage}" />
<h:inputText
value="#{portfolioTransactionBean.txnCurrentRecord.umptNotes}" />
</p:panelGrid>
<p:separator id="customSeparator" style="width:100%;height:10px" />
</p:column>
</p:dataTable>
<f:facet name="footer">
<p:commandButton value="Clear"
actionListener="#{portfolioTransactionBean.clearRecord}"
process="#this"
rendered="#{portfolioTransactionBean.onClickofButton}">
</p:commandButton>
<p:spacer width="100" height="10" />
<p:commandButton value="Save Transaction " icon="ui-icon-check"
action="#{portfolioTransactionBean.savePortfolioTransaction}"
style="float:right;right:20%;"
rendered="#{portfolioTransactionBean.onClickofButton}">
</p:commandButton>
<p:commandButton value="Add More Transaction " icon="ui-icon-check"
action="#{portfolioTransactionBean.addMoreTransPanel}"
process="#this" update="addMoreTrans"
rendered="#{portfolioTransactionBean.onClickofButton}" />
</f:facet>
</p:panelGrid>
<p:panelGrid columns="2" id="allTransactionPanel">
<p:dataTable value="#{portfolioTransactionBean.transactionsList}"
var="tradeRec">
<f:facet name="Header">
<h:outputText>Recently Added Trades</h:outputText>
</f:facet>
<p:column headerText="Company">
<h:outputText value="#{tradeRec.companyName}"></h:outputText>
</p:column>
<p:column headerText="Date">
<h:outputText value="#{tradeRec.umptTransDate}">
<f:convertDateTime dateStyle="medium"></f:convertDateTime>
</h:outputText>
</p:column>
<p:column headerText="Type">
<h:outputText value="#{tradeRec.umptTransType}"></h:outputText>
</p:column>
<p:column headerText="Quantity">
<h:outputText value="#{tradeRec.umptQty}"></h:outputText>
</p:column>
<p:column headerText="Price">
<h:outputText value="#{tradeRec.umptPrice}">
<f:convertNumber maxFractionDigits="2"></f:convertNumber>
</h:outputText>
</p:column>
<p:column headerText="Brokerage">
<h:outputText value="#{tradeRec.umptBrokerage}">
<f:convertNumber maxFractionDigits="2"></f:convertNumber>
</h:outputText>
</p:column>
</p:dataTable>
</p:panelGrid>
</p:panel>
</ui:define>
</ui:composition>
Template File...
<ui:composition xmlns:jsp="http://java.sun.com/JSP/Page"
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:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
template="./../templates/MasterTemplate.xhtml">
<ui:define name="moduleDetails">
<h:form name="portfolioMenuForm">
<f:event type="javax.faces.event.PreRenderViewEvent" listener="#{applicationScopeBean.preRenderView}"/>
<table style="width: 100%; min-height: 500px; border: none">
<tr>
<td>
<p:menu>
<p:submenu label="Portfolio Views">
<p:menuitem value="Add Transactions" action="PortfolioTransactionMgmt" update="#form" immediate="true" />
<p:menuitem value="View Transactions" action="PortFolioTranView" update="#form" immediate="true" />
<p:menuitem value="Latest Holdings" action="PortfolioHolding" update="#form" immediate="true" />
<p:menuitem value="Sector Allocations" action="#{portfolioTransactionBean.showSecAllocation}" update="#form" immediate="true" />
<p:menuitem value="Realized Profit" action="PortfolioRelizeProfit" update="#form" immediate="true" />
<p:menuitem value="Portfolio Performance" action="#{portfolioTransactionBean.showPortPerformance}" update="#form" immediate="true" />
<p:menuitem value="Benchmark Comparison" action="#{portfolioTransactionBean.showBenhComparison}" update="#form" immediate="true" />
</p:submenu>
</p:menu>
</td>
<td>
<ui:insert name="moduleContent"></ui:insert>
</td>
</tr>
</table>
</h:form>
</ui:define>
</ui:composition>
Basically this is not weired issue
On first click jsf first looks whether there is (javax.faces.ViewState) state available or not and if it is not available then it creates one for you & when you click second time because of Jsf state available it makes call to bean method.
Solution : try creating jsf state through the javascript function
Thanks to Çağatay Çivici Project lead of primefaces .He suggest me
Try with 2.1.17 then, showcase is 2.1.17.
So i updated my pom for jsf and it work like a charm.
Thanks

java.lang.IllegalStateException: Component ID already been found in the view

I have been getting this error. I added id's to all the components and also changed the session scope after reading a few other suggestions on stackOverflow.
I am trying to create a collapsible panel which contains tabs.
tabbb.xhtml
<cc:implementation>
<h:panelGroup layout="block" styleClass="collapsiblePanel-header">
<h:commandButton id="toggleButton"
action="#{cc.attrs.bean1.togglePanel}"
styleClass="collapsiblePanel-img"
image="#{cc.attrs.bean1.collapsed ? '/resources/images/plus.png' : '/resources/images/minus.png'}" />
</h:panelGroup>
<h:panelGroup layout="block" rendered="#{cc.attrs.bean1.collapsed}"
styleClass="collapsiblePanel-img2">
<cc:renderFacet name="tabs">
<js:forEach items="#{cc.attrs.bean2.tabBean}">
<h:outputText>"${cc.attrs.bean2.tabBean}"</h:outputText>
<li><h:commandLink
value="#{cc.attrs.bean2.tabBean.description}">
<f:param name="tabIndex" value="#{cc.attrs.bean2.randomNum}" />
<f:ajax event="click" render=":contentForm"
listener="#{bean2.handleTabChange}" />
</h:commandLink>
</li>
</js:forEach>
</cc:renderFacet>
</h:panelGroup>
<cc:insertChildren />
<h:outputStylesheet library="css" name="components.css" />
</cc:implementation>
using page: tabbedcollapsible.xhtml
<h:body>
<h:form id="testform">
<h:outputText value="Tabbed collapsible panel test page" />
<jl:tabbb bean1="${collPanel}" bean2="${tabbBean}">
<f:facet name="tabs">
<h:outputText value="This Is Cool" />
</f:facet>
</jl:tabbb>
</h:form>
</h:body>
Both the beans collPanel and tabbBean are request scoped.
Also the form does not render the tabs. I am new to JSF and I have been stuck with this for a long time. Thanks.

Resources