1
votes

I am usig jsf with richfaces 4.1, and want to modify a table content (delete given row) exactly the same way as in the showcase:

http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=dataTable&sample=dataTableEdit&skin=wine

but in my case the backing bean function don't get called. I also tried inserting alert() in a4j:jsFunction oncomplete event, but that also not called, and even tried to call deleteArchive() function directly from the commandbutton of the popup.
I have read different articles in the topic, but none of them solved my problem.

My code is the following:

<h:form class="page_frame">
    <rich:dataTable value="#{RunArchiveBean.archivedRuns}" var="run" id="run_table" style="margin-top: 50px; border: none !important; margin-left: auto; margin-right: auto;">
        <f:facet name="header">
            <h:outputText class="output_text_header" value="Session Run History" />
        </f:facet>
        <rich:column filterValue="#{RunArchiveBean.sessionNameFilter}"
                     filterExpression="#{fn:containsIgnoreCase(run.session.sessionName,RunArchiveBean.sessionNameFilter)}">
            <f:facet name="header">Session Name 
                <h:inputText value="#{RunArchiveBean.sessionNameFilter}">
                    <a4j:ajax event="keyup" render="run_table@body" execute="@this" />
                </h:inputText>
            </f:facet>
                <h:outputText value="#{run.session.sessionName}"></h:outputText>
        </rich:column>
        <rich:column>
            <f:facet name="header">Network</f:facet>
                <h:outputText value="#{run.session.network}"></h:outputText>
        </rich:column>
        <rich:column>
            <f:facet name="header">Network Element</f:facet>
                <h:outputText value="#{run.session.networkElement}"></h:outputText>
        </rich:column>
        <rich:column>
            <f:facet name="header">Creation Date of Session</f:facet>
                <h:outputText value="#{run.session.creationDate}"></h:outputText>
        </rich:column>
        <rich:column>
            <f:facet name="header">Run Date of Session</f:facet>
                <h:outputText value="#{run.logDate}"></h:outputText>
        </rich:column>
        <rich:column>
            <f:facet name="header">Results</f:facet>
            <a4j:commandLink execute="@this" action="#{SessionActionBean.showSessionLog(run.session, run.logDate)}" >
                <h:graphicImage id="log_image" name="log.png" library="images" style="border:0" />
                <rich:tooltip followMouse="true" target="log_image" value="Log" />
            </a4j:commandLink>
            <a4j:commandLink execute="@this" action="#{AnalyzerBean.setup(run.session, run.logDate)}">
                <h:graphicImage id="ida_icon" name="idaicon.png" library="images" style="border:0" />
                <rich:tooltip followMouse="true" target="ida_icon" value="IDA Results" />
            </a4j:commandLink>
            <h:commandLink id="hitLink" action="#{TraceBean.traceRead(run.session,run.logDate)}" disabled="#{!RunArchiveBean.fileExists(run.session, run.logDate, 'traceResult.log')}">
                <h:graphicImage id="hit_icon" name="#{RunArchiveBean.getHitIcon(run.session,run.logDate)}" library="images" style="border:0" />
                <rich:tooltip followMouse="true" target="hit_icon" value="HIT Results" />
            </h:commandLink>
            <a4j:commandLink id="delete_result" rendered="#{SessionActionBean.checkUserLevel()}" execute="@this" render="@none" onclick="#{rich:component('delete_archive')}.show();">
                <h:graphicImage id="delete_icon" name="delete.png" library="images" style="border:0"/>
                <rich:tooltip followMouse="true" target="delete_icon" value="Remove archived run" />
                <a4j:param value="#{run.index}" assignTo="#{RunArchiveBean.indexofDeleteArchive}"/>
            </a4j:commandLink>

        </rich:column>
    </rich:dataTable>

    <rich:jQuery selector="#run_table tr:odd" query="addClass('odd-row')" />
    <rich:jQuery selector="#run_table tr:even" query="addClass('even-row')" />

    <a4j:jsFunction name="deleteArchive" action="#{RunArchiveBean.removeArchivedRun}" render="run_table" execute="@this" oncomplete="#{rich:component('delete_archive')}.hide();" />

    <rich:popupPanel id="delete_archive" autosized="true" resizeable="false"
                 onmaskclick="#{rich:component('delete_archive')}.hide();">
        <f:facet name="header">
            <h:outputText value="Deleting archived run" />
        </f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('delete_archive')}.hide();">
                <h:graphicImage name="close.png" library="images" />
            </h:outputLink>
        </f:facet>
        <table>
            <tr>
                <td>
                    <h:outputText value="Are you sure to delete selected results?" />
                </td>
            </tr>
            <tr>
                <td>
                    <a4j:commandButton styleClass="fieldset_button" value="Yes" onclick="callRemove(); #{rich:component('delete_archive')}.hide(); return false;"/>
                </td>
                <td>
                    <a4j:commandButton styleClass="fieldset_button" value="Cancel" onclick="#{rich:component('delete_archive')}.hide();" />
                </td>
            </tr>
        </table>
    </rich:popupPanel>
</h:form>

with the script:

function callRemove() {
    deleteArchive();
}

Any ideas? Any help would be appreciated.

UPDATE #1:
a4j:jsFunction generates the following script on client side:

<script type="text/javascript"><!--
deleteArchive=function(){RichFaces.ajax("j_id_1d:j_id_2d",null,{"incId":"1"} )};
//--></script>

UPDATE #2:
Calling the removeArchivedRun() function directly from the a4j:commandButton action property also does not work, but calling other JavaScript form onclick method, like alert('It's working!), works.

1
Note that showcase uses RichFaces 4.3, some things may not workin RF 4.1. Can you call deleteArchive() from console? - Makhiel
It is known by Chromes InteliSense, but getting undefined error upon calling that. - Hodossy Szabolcs
I've updated to 4.3.5, but nothing different. - Hodossy Szabolcs
The bean names should start with a lowercase letter but I don't know if that's the problem. Check the generated HTML for the function definition, looks like the problem is there. - Makhiel
Changing bean names according to the above do not have any affect on the behavior on the page. - Hodossy Szabolcs

1 Answers

0
votes

Try moving in deleteArchive jsFunction inside popup panel and calling it directly instead of callRemove