I'm using the rich faces popup panel which contains the search criteria and the search results. I need to render the search results on click of he search button. I'm using <a4j:commandButton> for search button, on click of the button the results are not rendering.
<a4j:commandButton id="popupSearchButton" action="#{riskAreaSearchBean.search}"
styleClass="saveAsDraft" immediate="true" execute="areaPopupSearch"
value="#{riskLabel['customs.common.search']}" render="addAreaPopupPanel" />
"addAreaPopupPanel" is my popup panel id
If your addAreaPopupPanel is having rendered attribute set to false before onclick of your search button there is no chance of finding it in the DOM tree. Enclose it in a h:panelGroup or h:paneGrid which will always present in DOM and render that panelGroup or panelGrid.
*remove immediate=true as it will skip update modal values phase.
Hope this helps.
Related
I have a JSF page powered by a session-based backing bean. The page also includes a rich:popupPanel modal window which contains a form with couple of cascading elements and a couple of text boxes. The first time I input values into the form and press the Cancel button, the popup disappears. But when I click on the commandButton which displays the popup again, the drop-downs and input text boxes show the previously input values, even though I reset the underlying properties in the backing bean. It is as though the JSF UI elements' state is being cached, because for debugging purposes I print the underlying property values at the bottom of the popup and those are null (or empty).
Why is this happening and is there an effective way to reset the form UI elements' state?
Showing and hiding is just flipping between visible and invisible state. You need to rerender the popup every time you open it if you want it to use the current values.
Edit: Sample code
<a4j:commandButton render="popupPanelId" execute="#this"
oncomplete="#{rich:component('popupPanelId'}.show()" value="Click me" />
I have a search page for which I am using the Primefaces datatable and the backingbean scope is Viewscope. For the searchresults I am using the primefaces p:commandLink so when I click on the commandlink I will navigate to details page of that link. When I click on the browser back button from the details page it is navigating to the search page but the datatable is not displayed.
I need the datatable to be displayed with the results it has previously when I click on the browser back button from the details page.
Checked in the forums but could not find any solution for it. Any help is greatly appreciated.
I have a button that is supposed to close a modal panel and render several elements.
Is there an easy way to check if an element was rendered after the button was pressed?
example button:
<a4j:commandButton onclick="#{rich:component('modal')}.hide();"
style="background-repeat:no-repeat;width:18px;height:18px;"
image="includes/images/close.gif"
render=":id1 :id2">
<f:setPropertyActionListener target="#{Controller.attribute}" value="false" />
</a4j:commandButton>
I have another button that does not "work" on the un-rendered div.
The conditon of the rendered attribute of all of the button's parent components must be preserved when you're submitting the form. So it should not only evaluate true during the request of presenting the form with the button, but it should also evaluate true during the request of processing the form submit. Easiest is to put the backing bean in the view scope by #ViewScoped.
Also, if you're re-rendering a component which in turn contains a <h:form>, you need to explicitly add the client ID of that <h:form> to the render attribute. E.g. when component with client ID id1 has in turn a <h:form id="formOfId1">.
render=":id1 :id2 :formOfId1"
You can debug this all by just exploring the HTTP traffic in the webbrowser's developer toolset (press F12 in Chrome/IE9/Firebug and check the "Network" section).
See also:
commandButton/commandLink/ajax action/listener method not invoked or input value not updated - Points 5 and 7.
I have hit the same problem. My solution was to display the current time inside the element that i want to be rendered.
If, for instance, you want to render a panel, just paste inside that panel the following snippet:
<h:outputText value="#{session.lastAccessedTime}">
<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss.SSS" type="date" />
</h:outputText>
If the time is updated after button click, then obviously the component was rendered. But is the opposite also true? If the time is not updated, does this mean the component was not rendered? What if the component got rendered properly, but the time displayed is frozen to the moment the page was first accessed? I had small doubts about that, so i refreshed the page, and the time changed. So the time displayed is not frozen to the initial moment.
Also note that there are multiple ways to get the time; if you don't like to use session time, you could set a property in the backing bean, and initialize it to new Date()
I have a JSF page that includes a tree form tag which is rendered depending on some bean property. There are two buttons for next and previous page. I want to skip form validation on the button which goes to the previous page.
I tried the following ways to disable the validation:
Set h:commandButton immediate="true"
Change button by a4j:commandButton ajaxSingle="true" rerender="someparts"
It does not work. Why does the navigation fail when I want to skip validation?
immediate="true" does skip the validation. Make sure you have redeployed successfully, and the there aren't any errors.
I solve problem using a4j:commandButton ajaxSingle="true" reRender=":outhercomponent:formconteningcomponent:component"
reRender needs absolute path to component even if component id unique
dudes, does any of you know how to do this?
i have a page that has a datatable on it. it has a button to delete a row. the button works as expected, when you click it, it will delete the selected row/s. i also have another button that opens a popup window where you search for items and them add them to the said datatable. i am having a hard time figuring out how to refresh the datatable once you click the "select" button on the popup window.
my solution is having a hidden button that will refresh the datatable. it works when i litterally click it. but when i trigger the click event on the popup window using javascript, it doesnt always work. sometime it refreshes, sometimes it doesnt.
what's actually the best way to refresh a datatable?
If you use JSF2.0, there is an option to update part of your application with
<h:form>
...
...(here you have the binding data)
<h:commandButton action="#{yourbean.updateRows}" >
<f:ajax render="tableName" />
</h:commandButton>
</h:form>
EDITED
If you want to invoke it from JAVASCRIPT use:
document.getElementById('elementName').click();
How are you accessing your DataTable in the popup window ? by keeping it in some session variable and in you parent page are you displaying the datatable through some UI Component like GridView ? In that case you can reload your parent window from where you opned the popu windo through javascript. E.g. window.opener.location.reload();
I can think of .. Datatable.AcceptChanges(); But that's for C#..