0

in my application i'm calling a method using actionListener="#{jobsController.addSequence}" method and it is not working for some reason. And i can't see anything wrong with my code or with EL because it works in other places that i have used.

This is the code that's not working.

<p:dialog header="Remove Job" modal="true" widgetVar="remJob" minHeight="40" width="45%">
    <h:panelGroup styleClass="ContainerIndent" layout="block">

        <h:form id="removeJobForm">

            <h:panelGroup layout="block">
                <p:pickList id="jobPickList" value="#{jobsController.removeJobs}" var="jobs" itemLabel="#{jobs}" itemValue="#{jobs}"/>
            </h:panelGroup>

            <h:panelGroup styleClass="Seperator" layout="block"/>

            <h:panelGroup styleClass="Fright">
                <table border="0">
                    <tr>
                        <td width="110px" align="right">
                            <p:commandButton value="Reset" update="removeJobForm" process="@this" style="width:100px">
                                <p:resetInput target="removeJobForm" />
                            </p:commandButton>
                        </td>
                        <td width="110px" align="right">
                            <p:commandButton value="Submit" style="width:100px" onclick="PF('remJob').hide()" actionListener="#{jobsController.removeJobs}"/>
                        </td>
                    </tr>
                </table>

            </h:panelGroup>

        </h:form>
    </h:panelGroup>
</p:dialog>

This a working code that i have used the above method In this i have used this actionListener="#{jobsController.addSequence} as i have used it in the above code. And this is working without a problem.

<p:dialog header="Create Sequence" modal="true" widgetVar="addSeq" minHeight="40" width="50%">
    <h:panelGroup styleClass="ContainerIndent" layout="block">

        <h:form id="createSeqForm">
            <table border="0" width="100%">                                     
                <tr height="40px">      
                    <td>
                        <h:panelGroup layout="block" styleClass="Fleft">
                            <h:outputText value="Source Rollback After"/>
                        </h:panelGroup>
                        <h:panelGroup layout="block" styleClass="Fright">
                            <h:outputText value=":"/>
                        </h:panelGroup>
                    </td>

                    <td>
                        <h:panelGroup layout="block" styleClass="Fright">
                            <p:inputText style="width:197px" value="#{jobsController.jobBean.seqBean.src_rollback_after}" onkeypress="return isNumberKey(event)"/>
                         </h:panelGroup>
                    </td>
                </tr>

            </table>

            <h:panelGroup styleClass="Seperator" layout="block"/>

            <h:panelGroup styleClass="Fright">
                <table border="0">
                    <tr>
                        <td width="110px" align="right">
                            <!-- <p:growl id="growl" showDetail="true" sticky="true" autoUpdate="true" /> -->
                            <p:commandButton value="Reset" update="createSeqForm" process="@this" style="width:100px">
                        <p:resetInput target="createSeqForm" />
                            </p:commandButton>
                        </td>
                        <td width="110px" align="right">
                            <p:commandButton value="Submit" style="width:100px" update=":createJobForm:sequenceTable" onclick="PF('addSeq').hide()" actionListener="#{jobsController.addSequence}">
                                <p:resetInput target="createSeqForm" />
                                <!-- <p:ajax update=":createJobForm:sequenceTable" resetValues="true" /> -->
                                <!-- <p:poll id="poll" interval="5" update="growl" /> -->
                            </p:commandButton>
                        </td>
                    </tr>
                </table>
            </h:panelGroup>
        </h:form>
    </h:panelGroup>
</p:dialog>

Java method i'm trying to call

public DualListModel<String> getRemoveJobs(){
    List<String> source = new ArrayList<String>();
    List<String> target = new ArrayList<String>();

    try {           
        rs = db.select("SELECT JOB_ID FROM IM_JOBS");

        int count=0;

        while (rs.next()) {
            source.add(rs.getString("JOB_ID"));
            System.out.println(count);
            count++;
        }
        System.out.println("Removable Jobs Retrieved and added to the Source");

        jobs = new DualListModel<String>(source, target);
    } catch (SQLException e) {
        e.printStackTrace();
    }

    return jobs;
}

PS : I couldn't find any errors. No Exceptions, no validation errors or anything out of ordinary.

k9yosh
  • 858
  • 1
  • 11
  • 31
  • Is the method `generateNextUniqueJobID` not getting fired? or `addSequence` ? are there any javascript errors? check by pressing F12 while on the browser, and check the "console" tab for errors. And did you try chaning `onclick="PF('remJob').hide()"` to `oncomplete="PF('remJob').hide()"` or `onsuccess="PF('remJob').hide()"` ? – Ouerghi Yassine Jul 27 '15 at 12:00
  • Be specific to your problem, forget about what is working!, if *actionListener="#{jobsController.addSequence}" method and it is not working for some reason* than I am expecting `addSequence` method is your backing bean... – Sarz Jul 27 '15 at 12:01
  • You have a db select in your `getRemoveJobs` getter. This is bad, because: 1. the getter is usually called multiple times in one request; 2. the getter may return different results during different invocations, which could result in all sorts of problems. As to the actual problem you first say that it's the `addSequence` method that is not called, but then you say it's `getRemoveJobs`. – Vsevolod Golovanov Jul 27 '15 at 12:13
  • @OuerghiYassine sorry, it should be removeJobs in the code, where it is generateNextUniqueJobID. I have changed it now. No i did not try it because it is working fine and it's working perfectly the way it is in my second code that i have mentioned as working. I will try it though just to be sure. TY – k9yosh Jul 27 '15 at 16:13
  • @VsevolodGolovanov actually that's not the method i'm using there. I have a different method but since it's a big one i changed it to a different one (getRemoveJobs) where i recreated the same issue to read the code easily. TY for the tip though :) – k9yosh Jul 27 '15 at 16:16
  • @Sarz it is in my backing bean. What happens is it is not triggering anything at all when i press the button. Not even an error. The button does not do anything except refresh my pickList by an Ajax call (i guess). If you compare the two buttons in the code snippets i have attached, you can see that they are almost the same. But the 2nd one is working while the 1st isn't. – k9yosh Jul 27 '15 at 16:21
  • @BalusC I went through that answer before i posted the question. But i can't seem to get hold of the mistake i'm making here. Appreciate if you could point me out here. In the meantime i'll go through that answer again to see if i've missed anything. ty. – k9yosh Jul 27 '15 at 16:25
  • 1
    Better add confirmation that there are no "obvious" conversion/validation errors nor exceptions nor JS errors. Nothing in the question suggests that you've checked and excluded them. – BalusC Jul 27 '15 at 16:51
  • @BalusC i added a note. there are no validation errors, no exceptions (main reason i'm stuck) I have double checked everything. I will go through the JS calls once again to clarify whether i have not missed anything, – k9yosh Jul 27 '15 at 17:05
  • @k9yosh debug your code, as a quick suggestion set ajax=false; – Sarz Jul 28 '15 at 05:47
  • @BalusC I got an error and fixed my code. Now it's working. Because of an eclipse bug it didn't show the error. I changed my workspace and recreated the project. (Couldn't import because of another error where eclipse wouldn't let me add user libraries). And then it gave an error **NotWritablePropertyException**. And i figured it out. Should i delete this question or Post my answer? – k9yosh Jul 28 '15 at 08:21

0 Answers0