I am new to JSF and am working with an rich:extendedDataTable where one of the columns has an h:selectBooleanCheckbox as the header for select all purposes.
At the bottom of the table there is a a4j:commandButton (delete selected button) with an oncomplete action to launch a rich:popupPanel (confirm delete panel).
This all works fine, but when the table is refreshed, the select all checkbox remains checked after a delete is performed. In an effort to have it default to false when the table has been refreshed after a delete, I tried adding value="#{false}" to the checkbox. The problem is, when this value is set, my commandButton's oncomplete no longer gets invoked and is unable to show the pop-up panel.
I don't see the connection between the two, but maybe someone has an idea? Both the commandButton and extendedDataTable are within the same h:form For the time being, I am having my pop-up panel appear by using onbegin instead.
here is the code for my select all column.:
<rich:column id="modSelectColId" label="Selected">
<f:facet name="header">
<h:selectBooleanCheckbox id="selectAllId" onclick="selectAll(this)" value="#{false}"/>
</f:facet>
<h:selectBooleanCheckbox id="selectId" value="#{myBean.selectedMap[item]}" />
</rich:column>
here is the code for my command button:
<a4j:commandButton
value="Delete Selected"
oncomplete="#{rich:component('delSelectPopupId')}.show()" />
Related
I am using a SelectBooleanCheckBox inside a ui:repeat, and when I am repeating the content with a button, the state of the checkbox is also replicating. ie, if I checked the box for the first instance and i replicate the checkbox using ui:repeat then the second instance is also have the same state.
<ui:repeat var="mock" value="#{mockbean.mocking.mock}" id="mockRepeater" varStatus="mockStatus"
rendered="#{mockbean.mocking.hasmock()}" >
<h:selectBooleanCheckbox value ="MockcannotFind" id ="MockcannotFind_#{mockStatus.index}" class="MockcannotFind" onchange="jsFunction(#{MockcannotFind.index})" > // having some functionalities with Js Code
</h:selectBooleanCheckbox>
</ui:repeat>
<b:commandLink styleClass="addanotherbox" immediate="true"
rendered="#{mockbean.mocking.hasmock()}"
value="#{i18n['checkbox']}"
actionListener="#{mockbean.addMock()}" >
<f:param name="onAddAnotherBoxButton" value="true" />
</b:commandLink>
Could any one please help me on this?
I am new in Primefaces, and I encountered this problem. The action can not be performed unless I move onclick tag.
<p:commandButton value="Détail " action="#{Allcar.gethistorique}" onclick="detail();suppcar.disable();modifscar.disable();comptecar.disable();detcar.disable()"
id="deta" widgetVar="detcar" disabled="true">
</p:commandButton>
You have the commandButton initially set to disable="true". It won't submit if disabled. If you leave out the disabled="true", it works for me (though I am only using the detcar.disable() in the onclick)
<p:commandButton value="Détail " action="#{Allcar.gethistorique}" onclick="detcar.disable()"
id="deta" widgetVar="detcar">
</p:commandButton>
This is the situation:
I have a popup box to select one of the item listed(click the showParentAssetSearchButton) . Once selected the value of the selected item will be display in the main screen. In the main screen, there will be a button to clear up the item that selected. It will trigger an ajax action to the managed bean to clear the binding value(via click clearParentAssetButton).
When i do debugging, the value is clear and will not show in the main screen. However when i click on the save button, i notice that the property that should be empty is not actually empty. It still keep the value.
Following is the snippet UI code:
<h:panelGroup id="myregion">
<p:inputText id="parentAsset"
ondblclick="parentAssetDlg.show()"
value="#{assetMasterCreatePage.parentAsset.shortName}"
rendered="#{not empty assetMasterCreatePage.parentAsset}"/>
</h:panelGroup>
<p:commandButton icon="ui-icon-search"
id="showParentAssetSearchButton"
type="button"
title="#{msg.label_asset_search_parent_asset}"
onclick="parentAssetDlg.show()" />
<p:commandButton icon="ui-icon-trash"
id="clearParentAssetButton"
title="#{msg.label_asset_clear_parent_asset}"
actionListener="#{assetMasterCreatePage.doResetParentAsset}"
immediate="true"
process="#form"
update="clearParentAssetButton, myregion"
disabled="#{empty assetMasterCreatePage.parentAsset}" />
........
<p:commandButton value="#{msg.button_save}" icon="ui-icon-disk"
action="#{assetMasterCreatePage.doSaveAsset}" />
This is the managed bean snippet
#ManagedBean(name="assetMasterCreatePage")
#ViewScoped
public class AssetMasterCreatePage extends DefaultAssetMasterPage {
private AssetMaster assetMaster;
private AssetMaster parentAsset;
..........
.........
public void doResetParentAsset(){
parentAsset = null;
}
public String doSaveAssetMaster(){
assetMaster.setParentAsset(parentAsset);
assetMasterService.save(assetMaster);
MessageUtils.saveSuccessMessage();
return "save";
}
}
As you can see, when the button of the clearParentAssetButton is click, it will trigger ajax action #{assetMasterCreatePage.doResetParentAsset} to reset the value of the parentAsset. The issue here is when saving, the parentAsset which already should be null is not null.
I am using JSF 2 to perform the tasks.
Strange, is there any other fields which hold the value of parentAsset, I mean's in the page, have some fields like
<h:inputText value="parentAsset.shortName"/>, when you click the save button, a new parentAsset is initialized and saved, and also you can debug it and see the parentAsset's hash code to make sure whether the same one.
I'm working on an application that's basically a customised database administration tool.
The page structure is basically the following:
<a4j:region>
<h:selectOneMenu value='#{bean.selectedTable}'>
...
<a4j:ajax event='change' render='tablePanel'/>
</h:selectOneMenu>
<a4j:outputPanel id='tablePanel'>
<rich:extendedDataTable id='table' selection='#{bean.selectedRows}' ...>
<f:facet name='header'>
[datascroller etc.]
<a4j:commandButton action='#{bean.deleteSelectedRows}' execute='#region' render='tablePanel'/>
</f:facet>
[columns]
</rich:extendedDataTable>
</a4j:outputPanel>
<a4j:region>
The selectOneMenu is used to choose which database table will be displayed. The backing bean is request scoped and set up to pick the first available table as a default when it's initialised. I'm using an ExtendedDataTable subclass to paginate data in the database.
When I click the commandButton to delete the rows, it seems that the extendedDataTable component determines the selected rows /before/ the value of bean.selectedTable is applied. This means that no matter what table is selected in the dropdown menu, RichFaces tells me the selected rows are some (more or less arbitrary) rows in the default database table.
I verified that this is an ordering problem, when deleteSelectedRows() is called the value of selectedTable is correct. I'm using Richfaces 4 M6, and a4j:keepAlive doesn't seem to be there anymore to preserve the bean state.
Is there a way to tell RichFaces / JSF in which order to do these things? I tried using immediate="true" on the h:selectOneMenu but that didn't help.
Also, after a delete, the tablePanel doesn't seem to be rerendered, while another a4j:commandButton that adds new records with the same execute and render attributes seems to work fine. Is there a way to debug the state of RichFaces ajax requests / hook into them via events?
I am developing web application using JSF richfaces.I have one rich:modalpanel in main templete. This modalPanel have 'Your request is processing....." message.
I want to show this message(modalPanel) every action(ajax request). But without using a4j:status element.
Is there possible to acheive this(using listener or any otherway)?
How to show the wait modalPanel for all action using listener?
Help me about this.
Thanks in advance.
Update :
If i use my main templete,
<a4j:status id="waittingMessage"
onstart="javascript:Richfaces.showModalPanel('progressWaitModalPanel');"
onstop="javascript:Richfaces.hideModalPanel('progressWaitModalPanel');"/>
And i call the above a4j:status for the following places :
The following each and every component i use more than 100 place in my application
<a4j:commandButton status="waittingMessage"/>
<a4j:commandLink status="waittingMessage"/>
<h:selectOneMenu><a4j:support status="waittingMessage"/> </h:selectOneMenu>
<h:selectOneRadio><a4j:support status="waittingmessage"/></h:selectOneRadio>
<h:selectBooleanCheckbox><a4j:support status="waittingmessage"/></h:selectBooleanCheckbox>
In future,
i don't need to show the progressWaitModalPanel, that time i will delete a4j:status
in main templete.
But what about this status="waittingMessage"? Because this status="waittingmessage" i added more than 1000 places in my whole application.
<a4j:status> is the proper way to do this. I don't know of any other way. Perhaps you can hook to some low-level javascript, but that would be the wrong thing to do.
If the status is in the current form, there is no need to explicitly indicate which is the status - it is used by default.
<a4j:status id="waittingMessage"
onstart="Richfaces.showModalPanel('id_modalPanel')"
onstop="Richfaces.hideModalPanel('id_modalPanel')">
<f:facet name="start">
<label></label>
</f:facet>
<f:facet name="stop">
<label></label>
</f:facet>
</a4j:status>
<ui:include src="/modalPanel.xhtml" />
modalPanel.xhtml can contain display related content.
you can put the content above in a separate file say status.xhtml and then include it in your other pages
as below:
<a4j:outputPanel ajaxRendered="true">
<ui:include src="status.xhtml" />
</a4j:outputPanel>
so any page that has ajax request will display above message window
You need not add any status msg for each a4j:button ,etc.