rich:modalPanel appearing for some seconds only - jsf

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>

Related

CommandButton not invoked when changing pre populated values

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?

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"

JSF commanbutton refreshes the page and popup menu disappears immediately

I am trying to show a popup menu in by checking some conditions, such as if something is not selected show popup etc. and if everyhing is fine submit the page. Here is the code:
<h:commandButton onclick="if (#{moneyTransferManager.showPopup()})
#{rich:component('popup')}.show();" value="Devam" >
<rich:componentControl target="popup" operation="show" />
</h:commandButton>
<rich:popupPanel id="popup" modal="false" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="Simple popup panel" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#" onclick="#{rich:component('popup')}.hide();
return false;">
X
</h:outputLink>
</f:facet>
<p>
The popup panel is open and closed from the javascript function of component client side object. The following code
hide this panel:
<f:verbatim>#</f:verbatim> #{rich:component('popup')}.hide()
</p>
</rich:popupPanel>
then after button is clicked, popup shows for like a second and then page is refreshed and popup is lost. To prevent refreshing page i tried:
<f:ajax execute="#form" render="#none" />
but then if everything is right and if i don't need a popup i need to submit the page by commandbutton, but since i say render=#"none" i cannot do this. So what can i do about this situation?
Thanks
<h:commandButton> has a default button type submit which submits enclosing h:form when it is clicked. That is why the page refreshes when you click.
<h:button> should be used for java script usage.In addition, <h:commandButton> becomes <h:button> if type attribute is set to button.
<h:button onclick="if (#{moneyTransferManager.showPopup()})
#{rich:component('popup')}.show();" value="Devam"/>
Or
<h:commandButton type="button" onclick="if (#{moneyTransferManager.showPopup()})
#{rich:component('popup')}.show();" value="Devam" >
See Also :
Difference between h:button and h:commandButton

a4j Render not working

I have a modal panel similar to the one below in the xhtml page.
<h:form>
<a4j:commandLink action="" rerender="panel1">
</h:form>
<a4j:outputPanel id="panel1">
<rich:modalpanel>
<a4j:form>
<h:panelgroup binding=#{mybean.panel}/>
<a4j:commandButton id="save">
</a4j:form>
</rich:modalpanel>
</a4j:outputPanel>
When I click on the a4j command link,want to display the modal panel with differrent values. It works correctly if there is no a4j:form inside the modal panel. But I want to validate and save the attributes inside the modal panel on click of save button, and hence couldnt proceed with out the form component. But strangely when I add the a4j:form, panel group stop re rendering values. Please help me to sove this.
I also tried to place both inside same form, but then it worked in a very irregular manner.
Maybe try it this way:
<h:form>
<a4j:commandLink action="" rerender="panel1">
</h:form>
<rich:modalpanel>
<h:form>
<a4j:outputPanel id="panel1">
<h:panelgroup binding=#{mybean.panel}/>
<a4j:commandButton id="save">
</a4j:outputPanel>
</h:form>
</rich:modalpanel>
Works for me with Popuppanel

How to not close Richfaces popup after sumbit?

How can I prevent a popupPanel from closing after I sumbit a form inside it?
My code for button:
<h:commandButton value="Search" action="#{facesBean.search()}" >
<f:ajax execute="#form" render="result" />
</h:commandButton>
My code for the panel to be rendered after submit:
<h:panelGroup id="result" rendered="#{facesBean.list != null}">
TEST TO RERENDER
</h:panelGroup>
They're in the same h:form.
Is there something wrong? I don't get any error when running it.
There are basically two ways:
Just submit the form by ajax.
If you can't submit by ajax for some reason, just reopen the popup panel on postback.

Resources