1

The following save button code works well on mobile xpage:

var checkBox31:com.ibm.xsp.component.xp.XspInputCheckbox = getComponent("checkBox31");
var customerID1:com.ibm.xsp.component.xp.XspInputText = getComponent("customerID1");
var a = checkBox31.getValue();
var b = customerID1.getValue()
if (a == "" || a == null){
   if (b == ""){
   sessionScope.put("ITDialog","You must enter Customer ID");
   var dialog1:com.ibm.xsp.extlib.component.dialog.UIDialog = getComponent("dialog1");
    dialog1.show();
   }
   }

But it does not work on web xpage. I'm using 8.5.3FP6. I used 8.5.3FP1 and 8.5.3FP5 bu had same issue.

Thanks in advance for any help.

Here is sample of code which is not working.    

]]></xp:this.script>
                                </xp:executeClientScript>
                            </xp:this.script>
                        </xp:eventHandler>
                    </xp:button>
                    &#160;
                </xp:panel>
            </xe:dialog>
        </xp:panel>
        <xp:table>
            <xp:tr>
                <xp:td style="background-color:rgb(226,226,226)">
                    <xp:label
                        value="Company:"
                        id="company_Label1"
                        for="company1">
                    </xp:label>
                </xp:td>
                <xp:td>
                    <xp:inputText
                        value="#{document1.Company}"
                        id="company1">
                    </xp:inputText>
                </xp:td>
            </xp:tr>
            <xp:tr>
                <xp:td style="background-color:rgb(226,226,226)">
                    <xp:label
                        value="Address:"
                        id="address_Label1"
                        for="address1">
                    </xp:label>
                </xp:td>
                <xp:td>
                    <xp:inputText
                        value="#{document1.Address}"
                        id="address1">
                    </xp:inputText>
                </xp:td>
            </xp:tr>
            <xp:tr>
                <xp:td style="background-color:rgb(226,226,226)">
                    <xp:label
                        value="Contact person:"
                        id="contactPerson_Label1"
                        for="contactPerson1">
                    </xp:label>
                </xp:td>
                <xp:td>
                    <xp:inputText
                        value="#{document1.ContactPerson}"
                        id="contactPerson1">
                    </xp:inputText>
                </xp:td>
            </xp:tr>
        </xp:table>
    </xp:panel>
</xp:view>
Mohan Gangan
  • 127
  • 11

1 Answers1

1

A checkbox has a value of either 'false' or 'true' (indicating it is 'deselected' & 'selected'), it shouldn't return a value of "" or null. Therefore, the first if statement is never true, and your dialog will never appear.

I believe what you want is that if the checkbox is unselected, there must be a customer ID entered in the input. If so, I think this is the code you want:

var checkBox31:com.ibm.xsp.component.xp.XspInputCheckbox = getComponent("checkBox31");
var customerID1:com.ibm.xsp.component.xp.XspInputText = getComponent("customerID1");
var a = checkBox31.getValue();
var b = customerID1.getValue();
if (a == "false") {
    if (b == "") {
        sessionScope.put("ITDialog","You must enter Customer ID");
        var dialog1:com.ibm.xsp.extlib.component.dialog.UIDialog = getComponent("dialog1");
        dialog1.show();
    }
}
Brian Gleeson - IBM
  • 2,565
  • 15
  • 21
  • Tried the above solution but did not worked. Does it matter if the button enclosing panel don't have data but data enclosing panel has data? Your promptness is appreciated. - Mohan Gangan – Mohan Gangan Apr 01 '14 at 13:27
  • I tested it in an app I created on 901, and it worked there. I then tested it on an 853-FP4 server too, all worked. How did it fail? Was my assumption of what you want to happen correct? – Brian Gleeson - IBM Apr 01 '14 at 13:48
  • I'm validating field thru the propertied tab. But some fields needs to be validated thru button. I put the save button on top panel and data in different panel below the button panel. Did you tested in the same panel or different panels? The mobile xpage where code is working has one panel for save button and data. I've to use 8.5.3FP6 as it is current standard in the company. Thanks again. – Mohan Gangan Apr 01 '14 at 15:31
  • I just tried with everything in the same panel, and with the button in a separate panel, all worked fine (on 901 and 853). If you provided a full xpage example (and edit your original question to include it), it may be easier to find a solution – Brian Gleeson - IBM Apr 01 '14 at 15:45
  • Appreciated prompt response. I've extracted the small part of main xpage on a separate xpage and was able to reproduce the issue on 8.5.3FP6 client. – Mohan Gangan Apr 01 '14 at 17:48