0

selectOneMenu onchange から選択したアイテムを取得しようとしていますが、機能していません。ドロップダウンを変更して別のオプションを選択するたびに、Web ブラウザーのコンソールに次のように表示されます。

プロパティ 'getOffset' の値が null または未定義であり、Function オブジェクトではありません

これは、ProgramDetails.xhtml という名前の .xhtml ページです。

<h:dataTable id="DispatchConfigurationCustom" columnClasses="portlet-table-same portlet-table-cell" headerClass="portlet-table-same portlet-table-cell" value="#{CRUDOperatorProgram.workflowStepList}" var="workflowConfig" width="100%">
<h:column>
    <f:facet name="header">
        <h:outputText value="Include" />
    </f:facet>
    <h:selectBooleanCheckbox id="includeInd" value="#{workflowConfig.isIncludedInd}"/>
</h:column>
<h:column>
    <f:facet name="header">
        <h:outputText value="Automate" />
    </f:facet>
    <h:selectOneRadio id="onOff" value="#{workflowConfig.isAutomatedInd}">
        <f:selectItem id="onButton" itemLabel="On" itemValue="1" />
        <f:selectItem id="offButton" itemLabel="Off" itemValue="0" />
    </h:selectOneRadio>
</h:column>
<h:column>
    <f:facet name="header">
        <h:outputText value="Action Step" />
    </f:facet>
    <h:outputText value="#{workflowConfig.workflowStep.displayLabel}" />
</h:column>
<h:column>
    <f:facet name="header">
        <h:outputText value="Offset Prior" />
    </f:facet>
    <label for="offsetPriorBoxHour"><h:outputText value="hrs:" rendered="#{workflowConfig.workflowStep.displayLabel == 'Curtail Notification'}" /></label>
    <h:selectOneMenu styleClass="portlet-dropdown"  rendered="#{workflowConfig.workflowStep.displayLabel == 'Curtail Notification'}"  id="offsetPriorBoxHour" value="#{workflowConfig.offsetMinutes}" onchange="getOffset(this);">
        <f:selectItems value="${CRUDOperatorProgram.hourList}" />
    </h:selectOneMenu>
    <label for="offsetPriorBoxMin"><h:outputText value="min:" rendered="#{workflowConfig.workflowStep.displayLabel == 'Curtail Notification' or workflowConfig.workflowStep.displayLabel == 'Multisite Follow Up' or workflowConfig.workflowStep.displayLabel == 'Curtail Toggle'}" /></label>
    <h:selectOneMenu styleClass="portlet-dropdown"  rendered="#{workflowConfig.workflowStep.displayLabel == 'Curtail Notification' or workflowConfig.workflowStep.displayLabel == 'Multisite Follow Up' or workflowConfig.workflowStep.displayLabel == 'Curtail Toggle'}"  id="offsetPriorBoxMin" value="#{workflowConfig.offsetMinutes}" onchange="getOffset(this);">
        <f:selectItems value="${CRUDOperatorProgram.minuteList}" />
    </h:selectOneMenu>
</h:column>
<h:column>
    <f:facet name="header">
        <h:outputText value="Offset After" />
    </f:facet>
    <label for="offsetAfterBoxMin"><h:outputText value="min:" rendered="#{workflowConfig.workflowStep.displayLabel == 'Restore Notification' or workflowConfig.workflowStep.displayLabel == 'Overlapping Follow Up' or workflowConfig.workflowStep.displayLabel == 'Restore'}" /></label>
    <h:selectOneMenu styleClass="portlet-dropdown"  rendered="#{workflowConfig.workflowStep.displayLabel == 'Restore Notification' or workflowConfig.workflowStep.displayLabel == 'Overlapping Follow Up' or workflowConfig.workflowStep.displayLabel == 'Restore'}"  id="offsetAfterBoxMin" value="#{workflowConfig.offsetMinutes}" onchange="getOffset(this);">
        <f:selectItems value="${CRUDOperatorProgram.minuteList}" />
    </h:selectOneMenu>
</h:column>
<h:column>
    <f:facet name="header">
        <h:outputText value="Offset Target" />
    </f:facet>
    <h:outputText rendered="#{workflowConfig.workflowStep.displayLabel == 'Curtail Notification' or workflowConfig.workflowStep.displayLabel == 'Multisite Follow Up' or workflowConfig.workflowStep.displayLabel == 'Curtail Toggle'}"  id="offsetTargetStartBox" value="Start" />
    <h:outputText rendered="#{workflowConfig.workflowStep.displayLabel == 'Restore Notification' or workflowConfig.workflowStep.displayLabel == 'Overlapping Follow Up' or workflowConfig.workflowStep.displayLabel == 'Restore'}"  id="offsetTargetEndBox" value="End" />
</h:column>
<h:column>
    <f:facet name="header">
        <h:outputText value="Offset Summary" />
    </f:facet>
    <h:outputText rendered="#{workflowConfig.workflowStep.displayLabel == 'Curtail Notification' or workflowConfig.workflowStep.displayLabel == 'Multisite Follow Up' or workflowConfig.workflowStep.displayLabel == 'Curtail Toggle'}"  id="offsetSummaryBeforeBox" value="before Start time" />
    <h:outputText rendered="#{workflowConfig.workflowStep.displayLabel == 'Restore Notification' or workflowConfig.workflowStep.displayLabel == 'Overlapping Follow Up' or workflowConfig.workflowStep.displayLabel == 'Restore'}"  id="offsetSummaryAfterBox" value="after End time" />
</h:column>
<script>
    function getOffset( dropdown ) {
        var minutesTemp = dropdown.options[dropdown.selectedIndex].value;
        var minutes = minutesTemp.toString();
        alert("Minutes: " + minutes);
    // <![CDATA[
        if(document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetPriorBoxHour') != null) {
            var hourBox = document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetPriorBoxHour');
            var hourTemp = hourBox.options[hourBox.selectedIndex].value;
            var hour = hourTemp.toString();
            document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetSummaryBeforeBox').value = hours + " hours and " + minutes + " minutes before Start time";
        } else if(document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetSummaryBeforeBox') != null) {
            document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetSummaryBeforeBox').value = minutes + " minutes before Start time";
        } else { 
            document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetSummaryAfterBox').value = minutes + " minutes before Start time";
        }
        //]]>
    }

</script>
</h:dataTable>  

これらは、selectOneMenu...

private void loadMinuteList() {
    minuteList = new ArrayList<SelectItem>();
    for(Integer i=0; i<=60; i++){
        minuteList.add(new SelectItem(i, i.toString()));
    }
}

private void loadHourList() {
    hourList = new ArrayList<SelectItem>();
    for(Integer i=0; i<=30; i++){
        hourList.add(new SelectItem(i, i.toString()));
    }
}

長いコード ブロックで申し訳ありません。できるだけ多くの情報を提供しようとしています。JavaScript の使用方法に何か問題がありますか? または onchange=""?

4

2 に答える 2

1

スクリプトには 2 つの問題があります。

var minutesTemp = dropdown.options[dropdown.selectedIndex].value.;

.最後に追加を削除します

else (document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetSummaryBeforeBox') != null) {
   document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetSummaryBeforeBox').value = minutes + " minutes before Start time";
}

する必要があります

else if (document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetSummaryBeforeBox') != null) {
   document.getElementById('ProgramDetails:DispatchConfigurationCustom:0:offsetSummaryBeforeBox').value = minutes + " minutes before Start time";
}

ifつまり、の後に追加します-あまりにも含めない限りelse、使用時に条件を確認できませんelseif

于 2012-11-14T14:23:02.820 に答える
0

これを試してください:

<h:selectOneMenu styleClass="portlet-dropdown"  rendered="#{workflowConfig.workflowStep.displayLabel == 'Restore Notification' or workflowConfig.workflowStep.displayLabel == 'Overlapping Follow Up' or workflowConfig.workflowStep.displayLabel == 'Restore'}"  id="offsetAfterBoxMin" value="#{workflowConfig.offsetMinutes}" onchange="getOffset(offsetAfterBoxMin[index].value);">
    <f:selectItems value="${CRUDOperatorProgram.minuteList}" />
</h:selectOneMenu>

var minutesTemp = dropdown.options[dropdown.selectedIndex].value; : ORを削除します

<h:selectOneMenu styleClass="portlet-dropdown"  rendered="#{workflowConfig.workflowStep.displayLabel == 'Restore Notification' or workflowConfig.workflowStep.displayLabel == 'Overlapping Follow Up' or workflowConfig.workflowStep.displayLabel == 'Restore'}"  id="offsetAfterBoxMin" value="#{workflowConfig.offsetMinutes}">
    <f:selectItems value="${CRUDOperatorProgram.minuteList}" />
    <f:ajax event="valueChange" execute="getOgetOffset(offsetAfterBoxMin[index].value);"/>
</h:selectOneMenu>
于 2012-11-14T17:19:29.413 に答える