use of org.jaffa.components.codehelper.dto.CriteriaElementDto in project jaffa-framework by jaffa-projects.
the class CallBackDropdownHelper method getOptions.
public CodeHelperOutElementDto getOptions(HttpServletRequest request, String returnField, String descField, String domainName, CriteriaElementDto[] criteriaFields) throws ApplicationExceptions, FrameworkException {
CodeHelperOutElementDto m_dropDownCodes = null;
ApplicationExceptions appExps = null;
CodeHelperInDto input = null;
System.out.println("Still alive1");
if (m_codeHelperTx == null)
m_codeHelperTx = (ICodeHelper) Factory.createObject(ICodeHelper.class);
if (m_dropDownCodes == null) {
if (input == null)
input = new CodeHelperInDto();
CodeHelperInElementDto codeHelperInElementDto = new CodeHelperInElementDto();
codeHelperInElementDto.setCode("sort");
codeHelperInElementDto.setDomainClassName(domainName);
codeHelperInElementDto.setCodeFieldName(returnField);
codeHelperInElementDto.setDescriptionFieldName(descField);
for (int i = 0; i < criteriaFields.length; i++) {
CriteriaElementDto criteriaField = criteriaFields[i];
codeHelperInElementDto.addCriteriaField(criteriaField);
}
input.addCodeHelperInElementDto(codeHelperInElementDto);
}
// throw ApplicationExceptions, if any parsing errors occured
if (appExps != null && appExps.size() > 0)
throw appExps;
// Get the Codes and populate the respective fields
if (input != null) {
System.out.println("Still alive2");
input.setHeaderDto(getHeaderDto(request));
System.out.println("Still alive3");
CodeHelperOutDto output = m_codeHelperTx.getCodes(input);
if (output != null && output.getCodeHelperOutElementDtoCount() > 0) {
CodeHelperOutElementDto[] codeHelperOutElementDtos = output.getCodeHelperOutElementDtos();
for (int i = 0; i < codeHelperOutElementDtos.length; i++) {
CodeHelperOutElementDto codeHelperOutElementDto = codeHelperOutElementDtos[i];
String code = codeHelperOutElementDto.getCode();
if (code.equals("sort"))
m_dropDownCodes = codeHelperOutElementDto;
}
}
}
System.out.println("Still alive4");
return m_dropDownCodes;
}
use of org.jaffa.components.codehelper.dto.CriteriaElementDto in project jaffa-framework by jaffa-projects.
the class CodeHelperTx method processInputElement.
private CodeHelperOutElementDto processInputElement(UOW uow, CodeHelperInElementDto inputElement) throws ApplicationExceptions, FrameworkException {
Criteria c = new Criteria();
c.setTable(inputElement.getDomainClassName());
if (inputElement.getCriteriaFieldCount() > 0) {
CriteriaElementDto[] criteriaFields = inputElement.getCriteriaFields();
for (int i = 0; i < criteriaFields.length; i++) {
CriteriaElementDto criteriaField = criteriaFields[i];
addCriteria(criteriaField, c);
}
}
c.addOrderBy(inputElement.getCodeFieldName(), Criteria.ORDER_BY_ASC);
Iterator i = uow.query(c).iterator();
CodeHelperOutElementDto outputElement = new CodeHelperOutElementDto();
outputElement.setCode(inputElement.getCode());
outputElement.setDomainClassName(inputElement.getDomainClassName());
try {
while (i.hasNext()) {
Object domainObject = i.next();
Object code = BeanHelper.getField(domainObject, inputElement.getCodeFieldName());
Object description = BeanHelper.getField(domainObject, inputElement.getDescriptionFieldName());
CodeHelperOutCodeDto codeDto = new CodeHelperOutCodeDto();
codeDto.setCode(code);
codeDto.setDescription(formatDescription(inputElement, code, description));
outputElement.addCodeHelperOutCodeDto(codeDto);
}
} catch (NoSuchMethodException e) {
String str = "The CodeHelperTx could not introspect the Domain Class " + inputElement.getDomainClassName() + " for the code/description field";
log.warn(str, e);
}
return outputElement;
}
use of org.jaffa.components.codehelper.dto.CriteriaElementDto in project jaffa-framework by jaffa-projects.
the class DropDownTag method getHtml.
private String getHtml() {
String idPrefix = getHtmlIdPrefix();
StringBuffer b = new StringBuffer();
b.append("<select id = \"" + idPrefix + "\"" + (TagHelper.isEnclosed(pageContext) ? "" : " name=\"" + getField() + "WV\"") + " class=\"WidgetDropDown\">\n");
Object widgetValueObject = m_model.getWidgetValue();
String widgetValue = widgetValueObject != null ? m_propertyRuleIntrospector.format(widgetValueObject) : m_model.getStringValue();
// Build an option for display purposes.
if (this.getDomain() != null && widgetValue != null && widgetValue.length() > 0) {
CriteriaElementDto[] criteriaElementDtos;
criteriaElementDtos = new CriteriaElementDto[1];
CallBackDropdownHelper cbddHelper = new CallBackDropdownHelper();
CriteriaElementDto criteriaElementDto = new CriteriaElementDto();
criteriaElementDto.setFieldName(this.getDropdownValueField());
criteriaElementDto.setCriteria(StringCriteriaField.getStringCriteriaField(CriteriaField.RELATIONAL_EQUALS, widgetValue, null));
criteriaElementDtos[0] = criteriaElementDto;
try {
CodeHelperOutElementDto m_dropDownCodes = cbddHelper.getOptions((HttpServletRequest) pageContext.getRequest(), this.getDropdownValueField(), this.getDropdownDescField(), this.getDomain(), criteriaElementDtos);
for (int i = 0; i < m_dropDownCodes.getCodeHelperOutCodeDtoCount(); i++) {
m_model.addOption("" + m_dropDownCodes.getCodeHelperOutCodeDto(i).getDescription(), "" + m_dropDownCodes.getCodeHelperOutCodeDto(i).getCode());
}
} catch (ApplicationExceptions e) {
} catch (FrameworkException e) {
}
}
if (widgetValue == null)
widgetValue = "";
// Loop through display columns
List options = m_model.getOptions();
if (options != null) {
for (Iterator i = options.iterator(); i.hasNext(); ) {
SimpleWidgetModel.Option option = (SimpleWidgetModel.Option) i.next();
String label = option.getLabel();
if (label != null)
label = MessageHelper.replaceTokens(pageContext, label);
widgetValueObject = option.getWidgetValue();
String value = widgetValueObject != null ? m_propertyRuleIntrospector.format(widgetValueObject) : option.getStringValue();
if (value == null)
value = "";
b.append("<option value=\"" + StringHelper.convertToHTML(value) + "\"" + (value.equals(widgetValue) ? " SELECTED" : "") + ">" + label + "</option>\n");
}
}
b.append("</select>\n");
b.append(getWidgetRegistrationScript(idPrefix, false));
return b.toString();
}
Aggregations