views:

88

answers:

1
<rich:calendar id="orderpickDate" oninputfocus="check(#{myForm.packingListId})"

When creating a calendar you get an input field and an img that popups the calendar.

In the js function I can disable the input field:

function check(packId) {
  var canEditThisDate = true;

  // canEditThisDate = true/false <--  checked using jQuery.ajax() if date can still be
  // updated by the user


  if (! canEditThisDate) {
    jQuery("input[id='shipmentForm:orderpickDateInputDate']").attr("disabled", true);
  }
}

The input field can then not be changed manually. But you can still click on the img and select a date and then the input field is updated with the selected day.

How can I disable the richfaces popup in the js function?

A: 

Found a simple solution.

The input field id = shipmentForm:orderpickDateInputDate

The img id = shipmentForm:orderpickDatePopupButton

I Use following JQuery code:

        jQuery("[id*='shipmentForm:orderpickDate']").hover(function() {
            checkIfOrderPickDateCanBeUpdated(#{shipmentForm.currentPackingList.id});
        });

And hide/show the img:

    function checkIfOrderPickDateCanBeUpdated(packId) {
        var ret = false;

        jQuery.ajax({
              url: '/wms/seam/resource/dbutil?cmd=getFreightDocIdByPackId&amp;packId=' + packId,
              async: false,
              success: function(data) {
                  if (data == "0") {
                      ret = true;
                  } else {
                      ret = false;
                  }
             }
        });

        if (ret) {
            // enable order pick date field
            jQuery("input[id='shipmentForm:orderpickDateInputDate']").removeAttr("readonly");
            jQuery("img[id='shipmentForm:orderpickDatePopupButton']").show();
        } else {
            jQuery("input[id='shipmentForm:orderpickDateInputDate']").attr("readonly", true);

            jQuery("img[id='shipmentForm:orderpickDatePopupButton']").hide();
        }

        return ret;
    }
Guus