I'm using a <rich:datatable>
to display data from a List<Map<String, String>>
(in fact, that list has only one Map<String, String>
). The datatable
displays the data in a row and it shows an edit and a delete button next to the row.
When I click the delete button
I clear the register from that List
and from the database. I'd like, when I click the delete button
, not to display the content from the datatable
and disable the edit
and delete
buttons
. Here's the datatable code:
<rich:dataTable value="#{searchAuthDetailController.finalResults}"
id="table" var="result">
<c:forEach items="#{searchAuthDetailController.variableNames}" var="vname">
<rich:column>
<f:facet name="header">#{vname}</f:facet>
#{result[vname]}
</rich:column>
</c:forEach>
<rich:column>
<h:commandButton action="EditAuthor" value="Edit"
disabled="#{searchAuthDetailController.editBtDisabled}">
<f:setPropertyActionListener target="#{editAuthController.selectedAuthor}"
value="#{searchAuthDetailController.selectedAuthor}"/>
</h:commandButton>
</rich:column>
<rich:column>
<a4j:commandButton value="Delete" disabled="#{searchAuthDetailController.deleteBtDisabled}"
action="#{searchAuthDetailController.removeSelectedAuthor()}" render="table"/>
</rich:column>
</rich:dataTable>
Also there's a List<String>
displaying some links below the datatable
. I'd like those links and the text above not to appear anymore, after I click the delete button.
<h:outputText value="#{searchAuthDetailController.linksLabel}" />
<br />
<a4j:repeat value="#{searchAuthDetailController.sameasListToShow}" var="uri" >
<a href="#{uri}">#{uri}</a>
<br />
</a4j:repeat>
I'm using 2 variables called deleteBtDisabled
and editBtDisabled
as the value from the disabled property
from the buttons. At remove() (code below) I set those variables to true
and I clear the List<Map<String, String>>
, the variablenames List
, the List
of links displayed and linkslabel
.
Here's remove()
:
public void removeSelectedAuthor() {
this.authMapper.remove(bdModel, this.selectedAuthor);
this.variableNames.clear();
this.editBtDisabled = true;
this.deleteBtDisabled = true;
this.sameasListToShow.clear();
this.linksLabel = "";
}
Also, the delete button
has its render
property set to the datatable's
id.
With all those code, when I click the delete button, Only the content from the datatable disappear, but the buttons continue enabled and the list of links continue there.
How can I solve that problem?
i am not a Richfaces User. But:
1) an Action method of the JSF standard CommandButton should return the outcome Navigation String or Null ( in your case). ex.: public String removeItem() {...}
2) its recommended to Use List as value of datatables rather than maps, i don't know what type has your property
finalResults
3) if you use JSF 2.x then you can pass parameters to your actionMethods as EL ValueExpression:
action="#{searchAuthDetailController.removeSelectedAuthor(item.id)}"
, i recommend using<f:ajax ....>
for updating, then you can render/update only some parts of the pagei hope these help.
if you wish i can give you a working example (no richfaces ).
UPDATE: EXAMPLE
Bean: NOTE: no need to register your Bean in faces-config, instead i use here the Annotations to do that
User Object:
Form xhtml Page: