CommandButton not invoked when changing pre populated values - jsf

Anyone can please help me I am getting a weird issue I have list of records in datatable now i selected a record and click on Edit button now this selected record will be shown to popup window.
Now issue is that if i will edit selected value populated by previous window and press submit button page refreshing but action not invoked,but if i will change those value which not coming from parent Window or empty field in Popup Window then commandButton action Invoked.
Any one please tell me what the issue. What i am missing?
Parent Window is Session Scoped
Pop Window is View Scoped
JSF Version 2.1.13
Richfaces Version 4.3.5.Final
Javax.el 3.0.0
Servlet 2.4
el-api 2.2
el-impl 2.2
Jboss 7.1.0.Final
EDIT:-
PopUpWindow CommandButton Code
<a4j:commandButton
action="#{addFeaturePopUpBean.addFeature(parentBean)}"
value="#{bsmPortalLabel['button.common.submit']}"
image="/resources/images/submit-arrow.png"
render="cfsCreate,createRfs,createReso,notification,search-filter" >
<rich:tooltip id="toolemsSubmit" layout="block" >
<span style="white-space: nowrap">
#{bsmPortalLabel['tooltip.common.submit']}</span>
</rich:tooltip>
</a4j:commandButton>
EDIT1 :-
Exact Cause of the problem if i am using component link this
<h:inputText style="width:142px" id="featureName"
value="#{addFeaturePopUpBean.featuesObj.name}"
immediate="true"
validatorMessage="#{bsmPortalMessage['message.catalog.validation.compositeChar.name']}">
<f:validateRequired />
<f:validateRegex pattern="^[a-zA-Z0-9][a-zA-Z0-9_-]*$"></f:validateRegex>
<f:ajax event="blur" execute="featureName" render="msg1" />
</h:inputText>
<h:message id="msg1" for="featureName" style="color:red" />
Then commandButton invoked but if i will remove <f:ajax event="blur" execute="featureName" render="msg1" /> from the textBox now command not invoked .
But right now i am not able to figure out why this is happening?

Related

rich:modalPanel doesn't show up anymore if h:commandButton was clicked

First of all, this issue is on Edge only, everything works just fine on Chrome and Firefox.
I'm working with JSF 1.2 and RichFaces 3.3.3.Final (with community fix for IE9+).
I have a rich:modalPanel which is opened by a a4j:commandButton. On the modal panel there is a h:commandButton which hides the modal panel and exports a pdf generated with jasperReports. My issue is that after exporting a file for the first time, the modal panel doesn't show up anymore. I have to reload the page and then it works again. There's nothing new in console when I press a4j:commandButton to open the modal panel, the last log is "HTML1300: Navigation occured." which comes from pressing h:commandButton.
Open modal panel (contents.jspx) - sets printBean.showModalPanel to true:
<a4j:commandButton
image="/img/print.gif"
styleClass="clsCursorPointer"
action="#{ printBean.onExportReport}"
ajaxSingle="true"
reRender="printConfirmationPanel" />
Modal panel (forms.jspx):
<h:panelGroup id="printConfirmationPanel" >
<rich:modalPanel id="printConfirmationMP"
autosized="true"
showWhenRendered="true"
rendered="#{ printBean.showModalPanel}" >
<h:form>
<h:panelGrid columns="2" style="margin: auto">
<h:commandButton id="confirmButton" <--- Export button
value="#{ msgs['printButton']}"
actionListener="#{ printBean.onExportButton}" >
<f:attribute name="format" value="PDF"/>
(more attributes)
</h:commandButton>
<rich:componentControl
attachTo="confirmButton"
for="printConfirmationMP"
operation="hide"
event="onclick" />
</h:panelGrid>
</h:form>
</rich:modalPanel>
</h:panelGroup>
Problem is solved by updating Edge to version 81.0.416.53.

Commandbutton works only on second click until a <h:selectBooleanCheckbox> on a HashMap is removed

I'm working with JSF 2.2.9, i have the following dataTable and buttons:
<h:commandButton id="commandButtonRemoverSelected"
actionListener="#{managedBeanName.removeSelected()}"
class="btn btn-primary" value="Sim">
</h:commandButton>
<h:dataTable var="bean" value="#{managedBeanName.beans}" styleClass="table table-hover"
binding="#{managedBeanName.dataTable}">
<h:column headerClass="smallColumn">
<f:facet name="header">
<h:selectBooleanCheckbox valueChangeListener="#{managedBeanName.selectAll}">
<f:ajax execute="#form" render="#all" />
</h:selectBooleanCheckbox>
</f:facet>
<h:selectBooleanCheckbox value="#{managedBeanName.registrosSelecionados[bean]}" />
</h:column>
</h:dataTable>
The button "commandButtonRemoverSelected" just call actionListener on second click. When i remove the following line from datatabe everything works fine (the commandButton is called on first click):
<h:selectBooleanCheckbox value="#{managedBeanName.registrosSelecionados[bean]}" />
So, my managedBean have a MAP called 'registrosSelecionados' that should store a pair "Bean,Boolean". See:
private Map<Bean, Boolean> registrosSelecionados = new HashMap<Bean, Boolean>();
SOLUTION
I solved the problem with a workaround and i would share this:
1 - I noted that every first commandButton click the 'getRegistrosSelecionados()' is called and actionListener don't. So i imagine that JSF is processing getRegistrosSelecionados() and don't processing actionListener, i don't know why and this is the real problem. In second click the actionListener is processed because all checkboxs already sent to ManagedBean, in first click.
2 - So, my workaround is force that each click in checkbox call JSF request and don't wait for commandButton submit. In this way when commandButton is clicked all checkbox was processed.
<h:selectBooleanCheckbox value="#{cc.attrs.managedBeanName.registrosSelecionados[bean]}">
<f:ajax execute="#this" render="#this" />
</h:selectBooleanCheckbox>
My checkbox received the ajax to execute only itself and render itself, when i click in commandButton i just need execute the commandButton and render the form again:
<h:commandButton id="commandButtonRemoverSelected"
actionListener="#{cc.attrs.managedBeanName.removeSelected()}"
class="btn btn-primary" value="Sim">
<f:ajax execute="#this" render="#form" />
</h:commandButton>
This workaround works for me, as i didn't found a better solution for this problem.

Render rich:extendedDataTable

I need a rich:popup that shows a rich:extendedDataTable, and when the user presses a button, the popup should be shown, and the extendedDataTable must be re-rendered, here is the code:
<rich:popupPanel id="popupId" show="false" modal="true">
<h:form>
<rich:extendedDataTable
value="#{bean.list}"
var="item" rows="5" id="table">
<rich:column>
<h:outputLabel value="#{item}" />
</rich:column>
</rich:extendedDataTable>
<a4j:commandButton value="x" immediate="true"
oncomplete="#{rich:component('popupId')}.hide(); return false;"/>
</h:form>
</rich:popupPanel>
<h:form>
<a4j:commandButton value="show"
oncomplete="#{rich:component('popupId')}.show(); return false;"
render="table" immediate="true" />
</h:form>
The first time I press the show it works fine, but when I close the panel with the X button and press again the show button, the extendedDataTable appears empty (It's rendered but appear empty, see image below).
The problem is fixed if I add an empty extendedDataTable before the popup, like this:
<rich:extendedDataTable />
<rich:popupPanel>
...
With rich:dataTable the problem doesn't exits, but I need a extendedDataTable.
And aditional extrange behaviour is when I resize the browser, the data appears.
Platform
RichFaces: 4.2.2.Final
Spring: 3.1.1.RELEASE
Cheers
Use onclick instead of oncomplete. ExtendedDataTable doesn't render properly inside invisible elements (it's a bug) so the popupPanel has to be made visible before the rerendering.
I had kinda the same issue.
I solved it in a not 100% richface correct way:
<a4j:commandButton
value="show"
action="#{actionForm.setShowEditor('true')}"
oncomplete="javascript:location.reload(true)"/>
<a4j:region layout="block" rendered="#{actionForm.showEditor}" id="panelArea">
<rich:popupPanel id="#{popupID}" modal="true" show="true" domElementAttachment="parent">
....
tabel
buttons
....
</rich:popupPanel>
</a4j:region>
The popup is always shown (show="true") inside the a4j:region.
But the a4j:region is only shown if variable to show the popup = true.
The full page refresh was in my case needed because otherwise my ckeditor had some initialisation errors. It should also work if you only rerender the a4j:region after you set the "#{actionForm.setShowEditor('true')}.

Popup not rendering in JSF

I have a4j command button in one xhtml page and popup panel in other. I want to open the the popup on commandbutton click in first page.
the command button
auth.xhtml
<a4j:commandButton id="Add" value="Add New" type="submit"
action="#{controller.add}"
render=":addPopupForm:addPopupOp">
<a4j:param value="true" assignTo="#{controller.ind}" ></a4j:param>
</a4j:commandButton>
addPopup.xhtml
<h:form id="addPopupForm">
<a4j:outputPanel id="addPopupOp" ajaxRendered="true">
<rich:popupPanel id="addPopup" domElementAttachment="parent" show="true"
rendered="true" height="600" width="1000" >
Row is added
</rich:popupPanel>
</rich:outputPanel>
</h:form>
I'm not a richfaces user but in general JSF , you can't re-render elements which are not rendered in the first place.
So in your case you should point to addPopupForm , like this :
<a4j:commandButton id="Add" value="Add New" type="submit"
action="#{controller.add}"
render=":addPopupForm" >
Or wrap the a4j:outputPanel with some wrapper that will be always rendered
Also, take a look at this: Can you update an h:outputLabel from a p:ajax listener?
Just rendering the panel does not mean showing it. You have to attach the popup "show" attribute to a property:
show="#{bean.showPopup}"
Set the showPopup boolean in the action method (action="#{controller.add}") and then do render="addPopupForm"

rich:modalPanel appearing for some seconds only

I have used rich:menuItem to display rich:modalpanel. Code of rich:menuItem is as follow:
<rich:menuItem>
<a4j:commandLink
value="Add Machine"
oncomplete="#{rich:component('addMachinePanel')}.show()"
reRender="addMachinePanel">
</a4j:commandLink>
</rich:menuItem>
And rich:modalpanel code is
<rich:modalPanel id="addMachinePanel">
<a4j:form>
<a4j:commandButton value="Cancel"
action="#{adminBean.cleanupMachineToEdit}"
onclick="#{rich:component('addMachinePanel')}.hide(); return false;" />
</a4j:form>
</rich:modalPanel>
With above piece of code, rich:modalpanel is appearing for one or two seconds and again disappear.
Please help me to find out the issue.
Thanks
By default , the submitMode attribute for the rich:menuItem is server , which will submit the form and completely refreshes the page.
You can change the submitMode to the ajax to performs an ajax form submission. Only the elements specified with the reRender attribute will be refreshed instead of whole page.
Or , you can change it to none (for richfaces 3.X) or client (for richface 4.0) such that there are no form submission.
<rich:menuItem submitMode="ajax">
<a4j:commandLink
value="Add Machine"
oncomplete="#{rich:component('addMachinePanel')}.show()"
reRender="addMachinePanel">
</a4j:commandLink>
</rich:menuItem>

Resources