I am using richfaces and jsf.
I am using <rich:tabpanel> to create the tabs.
I have taken 4 tabs.
In 1st tab , one refresh button is available. If I click that button, the whole tabpanel is refreshed. whatever the data is kept in tab2, tab3 and tab4 will be clear.
use <a4j:support reRender="tabPanelComponentId"> inside your button, or use <a4j:commandButton reRender="tabPanelComponentId" />
Related
Hi I have a JSF "Register.xhtml" inside I have two Primefaces Command Buttons:
<p:commandButton id="registerButton"
action="#{registerController.register()}" rendered="#{!registerController.IsUserRegistered()}" />
<p:commandButton id="unregisterButton"
action="#{registerController.unregister()}" rendered="#{registerController.IsUserRegistered()}"/>
It works if I manually refresh the page.
I want a method to show the unregisterButtonand hiding the registerButton after I call the
registerController.register() function by clicking on the register Button.
You need to refresh the part of the page where the second button is after the click on the first button.
With Primefaces you can use PartialSubmit, http://www.primefaces.org/showcase/ui/ajax/partialSubmit.xhtml
I want to change a tab by clicking in commandButton. I'm controlling activeIndex on my bean and doing an update on tabView component. Everything works fine.
My problem is that I want to change the activeIndex without need doing an update on tabView, because update of that component is a bit slow.
Is it possible to change a tab by clicking on button, and do that without update?
Here is my actual code.
TabView component
<p:tabView id="tvFoo" dynamic="true" activeIndex="#{fooBean.activeIndex}">
<p:tab title="Title" id="someTab">
<ui:include src="someTabName.xhtml" />
</p:tab>
<p:tab title="Title2" id="anotherTab">
<ui:include src="anotherTabName.xhtml" />
</p:tab>
</tabView>
inside someTabName.xhtml
<p:commandButton value="go to anotherTab" actionListener="#{fooBean.tabChange('anotherTabName')}" />
fooBean, that controls tabs change
public void tabChange(String tabId) {
switch (tabId) {
case "anotherTabName":
activeIndex = 2;
RequestContext.getCurrentInstance().update("tvFoo"); //here is the line that I don't want to call
break;
}
Can I remove that line, RequestContext.getCurrentInstance().update("tvFoo");? Of course, if simply remove, the tab is not changed.
To resume, basically I want change the opened tab. I think that I can achieve this calling the changeTab event manually, but I don't know how do that.
Why don't you do an update on the tabview component by your command button?
I think you have to do an update somewhere, otherwise, how should the tabview notice the change? Moreover, as far as I know, the update function isn't slow at all.
To get the current index of the tabview you could play with the Faces Context:
TabView tabView = FacesContext.getCurrentInstance().getViewRoot().findComponent(aComponentId);
On tabView you can get and set the active tab individually.
I hope this helps, good luck!
Have you tried using the wizard component? I believe the behaviour you're looking for is similar to this primefaces wizard.
http://www.primefaces.org/showcase/ui/panel/wizard.xhtml
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#..
I am using jsf with Richfaces. I've created a tabpanel using <rich:tabpanel>. I have taken 4 tabs like tab1, tab2, tab3 and tab4. if I run the application tab1 is default one. If I go to next tab I use navigation for every tab like NEXT<< and PREV>> .
If I click on a tab label, it is also changing the tabs. if I run the application, I want tab1 to be active and all others tabs are disabled (like tab2 or tab3 are disabled. If I click navigation buttons, only the tabs will be active.)
If I run the application, the tab1 will be active after fill up the tab1 details click the NEXT<< navigation then tab2 is active. Now the tab1 and tab2 are active. tab3 and tab4 are inactives.
What are the solution for the above two questions?
<rich:tabPanel switchType="ajax">
<rich:tab label="First">
Here is tab #1
</rich:tab>
<rich:tab label="Second" disabled="true">
Here is tab #2
</rich:tab>
<rich:tab label="Third" disabled="true">
Here is tab #3
</rich:tab>
</rich:tabPanel>
here second and third tab will be disabled , you can do something like
disabled= #{Bean.isDisabledTab1}
And handel it on next ,previous
Complementing org.life.java answer, you can add an action listener to the button or link that you are clicking when you switch tabs, for example:
<a4j:commandLink id="identifierLink" value="#{bean.ID_COUNT}"
actionListener="#{bean.switchTab}" reRender="clientTabPanel, clientTable">
<f:param id="internalID" value="#{bean.INTERNAL_ID}" name="internalIDParam"/>
</a4j:commandLink>
The switchTab action listener method would contain the logic to enable or disable the other tabs (just like org.life.java mentioned), and you could use f:param in case you want to pass something to your action listener when deciding to switch or not. I think you need to re-Render the tabPanel when you update the related property for the "disabled" attribute.
I m trying to open a rich modal panel with populated data on a button click
tried
<h:commandButton id="btn_search" value="#{text['button.add']}"
action="#{cartBean.search}"
oncomplete="#{rich:component('dlg_results')}.show()">
</h:commandButton>
and
<h:commandButton id="btn_search" value="#{text['button.add']}"
action="#{cartBean.search}" immediate="true">
<rich:componentControl for="dlg_results" attachTo="btn_search" operation="show" event="onclick"/>
</h:commandButton>
This code opens the model panel on button click but when response is sent back from the server the whole page gets refreshed
can some one suggest a way to handle this ???
Use <a4j:commandButton> instead of h:commandButton.
Thanks, this was helpful information.
I used showWhenRendered tag in rich:modalpanel to solve my problem. I added a variable in my bean and set its value to true on click of button if records are found.