Пример #1
0
  @Override
  protected JSONObject renderContent() throws JSONException {
    JSONObject json = super.renderContent();
    json.put(JSON_TEXT, selectedEntityValue);
    json.put(JSON_CODE, selectedEntityCode);
    json.put(JSON_ACTIVE, selectedEntityActive);
    json.put(JSON_BELONGS_TO_ENTITY_ID, belongsToEntityId);

    if (clearCurrentCodeCode) {
      json.put(JSON_CLEAR_CURRENT_CODE, clearCurrentCodeCode);
    }

    if (autocompleteMatches != null) {
      JSONArray matches = new JSONArray();
      for (Entity entity : autocompleteMatches) {
        JSONObject matchEntity = new JSONObject();
        matchEntity.put("id", entity.getId());
        matchEntity.put("value", ExpressionUtils.getValue(entity, expression, getLocale()));
        matchEntity.put("code", String.valueOf(entity.getField(fieldCode)));
        matchEntity.put("active", entity.isActive());
        matches.put(matchEntity);
      }
      json.put(JSON_AUTOCOMPLETE_MATCHES, matches);
      json.put(JSON_AUTOCOMPLETE_CODE, autocompleteCode);
      json.put(JSON_AUTOCOMPLETE_ENTITIES_NUMBER, autocompleteEntitiesNumber);
    }

    if (criteriaModifierParameter != null && !criteriaModifierParameter.isEmpty()) {
      json.put(JSON_CRITERIA_MODIFIER_PARAMETER, criteriaModifierParameter.toJSON());
    }

    return json;
  }
Пример #2
0
 @Override
 public void setFilterValue(FilterValueHolder value) {
   if (criteriaModifier == null) {
     throw new IllegalStateException(CRITERIA_MODIFIER_NOT_PRESENT);
   }
   criteriaModifierParameter.initialize(value.toJSON());
   requestRender();
 }
Пример #3
0
  @Override
  protected void initializeContent(final JSONObject json) throws JSONException {
    super.initializeContent(json);

    if (json.has(JSON_TEXT) && !json.isNull(JSON_TEXT)) {
      selectedEntityValue = json.getString(JSON_TEXT);
    }
    if (json.has(JSON_CODE) && !json.isNull(JSON_CODE)) {
      selectedEntityCode = json.getString(JSON_CODE);
    }
    if (json.has(JSON_BELONGS_TO_ENTITY_ID) && !json.isNull(JSON_BELONGS_TO_ENTITY_ID)) {
      belongsToEntityId = json.getLong(JSON_BELONGS_TO_ENTITY_ID);
    }
    if (json.has(JSON_OLD_SELECTED_ENTITY_ID) && !json.isNull(JSON_OLD_SELECTED_ENTITY_ID)) {
      oldSelectedEntityId = json.getLong(JSON_OLD_SELECTED_ENTITY_ID);
    }

    if (json.has(JSON_CURRENT_CODE) && !json.isNull(JSON_CURRENT_CODE)) {
      currentCode = json.getString(JSON_CURRENT_CODE);
    }

    if (json.has(JSON_AUTOCOMPLETE_CODE) && !json.isNull(JSON_AUTOCOMPLETE_CODE)) {
      autocompleteCode = json.getString(JSON_AUTOCOMPLETE_CODE);
    }

    if (json.has(JSON_CRITERIA_MODIFIER_PARAMETER)
        && !json.isNull(JSON_CRITERIA_MODIFIER_PARAMETER)) {
      criteriaModifierParameter.initialize(json.getJSONObject(JSON_CRITERIA_MODIFIER_PARAMETER));
    }

    if (belongsToFieldDefinition != null && belongsToEntityId == null) {
      setEnabled(false);
    }
  }