Exemplo n.º 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;
  }
Exemplo n.º 2
0
 private void refresh() {
   Long entityId = getFieldValueWithoutSearching();
   if (entityId == null) {
     selectedEntityCode = "";
     selectedEntityValue = "";
     selectedEntityActive = true;
     return;
   }
   Entity entity = getDataDefinition().get(entityId);
   if (entity == null) {
     setFieldValueWithoutRefreshing(null);
     selectedEntityCode = "";
     selectedEntityValue = "";
     selectedEntityActive = true;
   } else {
     selectedEntityCode = String.valueOf(entity.getField(fieldCode));
     selectedEntityValue = ExpressionUtils.getValue(entity, expression, getLocale());
     selectedEntityActive = entity.isActive();
   }
 }