Package org.openmrs.layout.web.name

Examples of org.openmrs.layout.web.name.NameTemplate


  }

  @Override
    public String generateHtml(FormEntryContext context) {
    MessageSourceService messageSourceService = Context.getMessageSourceService();
    NameTemplate defaultLayoutTemplate = NameSupport.getInstance().getDefaultLayoutTemplate();
    TextFieldWidget textFieldWidget;
    Map<String, String> fieldMap;

    if (!isRegistered) {
      registerWidgets(context);
      isRegistered = true;
    }

    // have the date and time widgets generate their HTML
    StringBuilder sb = new StringBuilder();

    sb.append("<table>");

    List<List<Map<String, String>>> fieldLines = defaultLayoutTemplate.getLines();

    for (List<Map<String, String>> line : fieldLines) {
      sb.append("<tr>");
      int colIndex = 0;
      for (Iterator<Map<String, String>> iterator = line.iterator(); iterator.hasNext(); colIndex++) {

        fieldMap = iterator.next();

        if (fieldMap.get("isToken").equals(defaultLayoutTemplate.getLayoutToken())) {

          String label = messageSourceService.getMessage(fieldMap.get("displayText"));
          textFieldWidget = widgetMap.get(fieldMap.get("codeName"));
          textFieldWidget.setTextFieldSize(Integer.parseInt(fieldMap.get("displaySize")));
          sb.append("<td>").append(label).append("</td>");
          if (!iterator.hasNext() && colIndex < defaultLayoutTemplate.getMaxTokens()) {
            sb.append("<td colspan='").append(defaultLayoutTemplate.getMaxTokens() - colIndex).append("'>");
          }
          else {
            sb.append("<td>");
          }
          sb.append(textFieldWidget.generateHtml(context)).append("</td>");
View Full Code Here

TOP

Related Classes of org.openmrs.layout.web.name.NameTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.