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?
Related
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()" />
I have a question concerning the jsf component . Here is a small code example:
<ui:repeat var="bean" value="myBean.myListToIterate">
<h:selectOneCheckbox value="#{myBean.specificField}" />
#{bean.car.name}
</ui:repeat>
Question 1: Why the expression #{bean.car.name} alone inside the ui:repeat element and why not for example in a
<h:outputLabel value="#{bean.car.name}" />"?
If i use this, nothing will be displayed.
Question 2: Why does this example doesn´t look very well, if i use a
<h:selectOneRadio value="#{myBean.specificField}"/> component
instead of a
<h:selectOneCheckbox value="#{myBean.specificField}"/> component?
Greetz
Marwief
Answer 1 :
EL JSF expressions are allowed in the last JSF versions. So it can be put without any wrapping tag (like <h:outputText />).
Using this <h:outputLabel value="#{bean.car.name}" /> did not give result, because you did not specify for attribute to point to, in order to be rendered as label of its client id, which means, it cannot be used alone.
Answer 2 :
First, this JSF tag <h:selectOneCheckbox /> doesn't exist, maybe you wanted to mean <h:selectBooleanCheckbox />. Replacing this by <h:selectOneRadio ... /> does not look very well, because this last one needs <f:selectItem /> or <f:selectItems /> to hold choices from where the end user will be able to choose between (i.e at least 2 choices), in the contrary of <h:selectBooleanCheckbox /> which can have no child select item(s) tag(s) in the case of one alone choice to (un)check.
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 have two grids, and one tabView which contains 2 tabs, for first tab I have to show panelgrid1, and for tab2 = panelgrid2. I have used rendered attribute for both panels, and used tabchange event in tabView, this listener updates the status attribute in java, but in xhtml, same grid is still shown and doesn't change 2nd panelgrid.
You need to make absolutely sure that you refer in ajax update/render a component which is always rendered. It is not possible to refer a component which is by itself conditionally rendered in order to show/hide it.
<p:ajax ... update="foo" />
...
<h:panelGroup id="foo">
<h:panelGrid ... rendered="#{bean.grid == 1}">
...
</h:panelGrid>
<h:panelGrid ... rendered="#{bean.grid == 2}">
...
</h:panelGrid>
</h:panelGroup>
See also:
Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?
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.