use of org.jaffa.components.codehelper.dto.CodeHelperOutElementDto 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.CodeHelperOutElementDto 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.CodeHelperOutElementDto in project jaffa-framework by jaffa-projects.
the class FinderComponent2 method initializeSavedQueries.
private void initializeSavedQueries() {
/*
* Read the stored queries and and create a codeHelperOutElementDto so
* that this can be used as the options to a dropdown
*/
// Get the saved Queries
IContextManager contextManager = ContextManagerFactory.instance();
QuerySaver querySaver = new QuerySaver(contextManager);
Map savedQueries = querySaver.getSavedQueryList(getComponentDefinition().getComponentName());
String defaultQueryId = querySaver.getDefaultQueryId(getComponentDefinition().getComponentName());
m_queryIdCodes = new CodeHelperOutElementDto();
if (savedQueries.size() > 0) {
// Create the codeHelperOutElementDto by iterating over the key maps
Iterator savedQueriesIterator = savedQueries.keySet().iterator();
while (savedQueriesIterator.hasNext()) {
String element = (String) savedQueriesIterator.next();
log.info("Adding " + element + " to Saved Queries");
CodeHelperOutCodeDto codeHelperOutCodeDto = new CodeHelperOutCodeDto();
codeHelperOutCodeDto.setCode(element);
if (defaultQueryId != null && element.equals(defaultQueryId)) {
codeHelperOutCodeDto.setDescription("** " + savedQueries.get(element) + " **");
} else {
codeHelperOutCodeDto.setDescription(savedQueries.get(element));
}
m_queryIdCodes.addCodeHelperOutCodeDto(codeHelperOutCodeDto);
}
} else {
log.info("No Queries to add to Saved Queries");
CodeHelperOutCodeDto codeHelperOutCodeDto = new CodeHelperOutCodeDto();
codeHelperOutCodeDto.setCode("");
codeHelperOutCodeDto.setDescription(MessageHelper.findMessage("label.Jaffa.Finder.NoSavedQueries", null));
m_queryIdCodes.addCodeHelperOutCodeDto(codeHelperOutCodeDto);
}
}
use of org.jaffa.components.codehelper.dto.CodeHelperOutElementDto in project jaffa-framework by jaffa-projects.
the class FinderForm method getSavedQueryIdWM.
/**
* Getter for property savedQueryId. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
* @return Value of property savedQueryId.
*/
public DropDownModel getSavedQueryIdWM() {
DropDownModel w_savedQueryId = (DropDownModel) getWidgetCache().getModel("savedQueryId");
if (w_savedQueryId == null) {
w_savedQueryId = new DropDownModel((getSavedQueryId() != null ? "" + getSavedQueryId() : ""));
CodeHelperOutElementDto dto = ((FinderComponent2) getComponent()).getSavedQueryIdCodes();
if (dto != null && dto.getCodeHelperOutCodeDtoCount() > 0) {
CodeHelperOutCodeDto[] codes = dto.getCodeHelperOutCodeDtos();
for (int i = 0; i < codes.length; i++) {
CodeHelperOutCodeDto code = codes[i];
w_savedQueryId.addOption(Formatter.format(code.getDescription()), Formatter.format(code.getCode()));
}
}
getWidgetCache().addModel("savedQueryId", w_savedQueryId);
}
return w_savedQueryId;
}
use of org.jaffa.components.codehelper.dto.CodeHelperOutElementDto 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