/** @throws IOException */
 public void doTag() throws IOException {
   final JspWriter out = this.getJspContext().getOut();
   out.append("<input");
   writeAttribute(out, "type", "password");
   writeAttribute(out, "name", getName());
   if (getShowValue()) {
     writeValue(out);
   } else {
     getDynamicAttrs().remove("value");
   }
   writeDynamicAttributes(out);
   out.append(" />");
   return;
 }
Example #2
0
  @Override
  public void doTag() throws JspException, IOException {
    final boolean enabled = Config.getBoolean(ENABLE_TEST_IDS_PROPERTY, false);
    if (enabled) {
      final PageContext pageContext = (PageContext) getJspContext();
      final JspWriter jspWriter = pageContext.getOut();

      final int nextUniqueId = getNextUniqueId(pageContext);

      jspWriter
          .append("<div id=\"")
          .append("test_")
          .append(cleanupHtmlId(getCode()))
          .append("_$")
          .append(String.valueOf(nextUniqueId))
          .append("\" style=\"display:inline\">");

      // Write the body out
      getJspBody().invoke(jspWriter);

      jspWriter.println("</div>");
    } else {
      // Just render the contents
      getJspBody().invoke(getJspContext().getOut());
    }
  }
 /**
  * Test method for {@link org.apache.tiles.request.jsp.JspPrintWriterAdapter#append(char)}.
  *
  * @throws IOException If something goes wrong.
  */
 public void testAppendChar() throws IOException {
   JspWriter writer = createMock(JspWriter.class);
   expect(writer.append('c')).andReturn(writer);
   JspPrintWriterAdapter adapter = new JspPrintWriterAdapter(writer);
   replay(writer);
   assertEquals(adapter, adapter.append('c'));
   verify(writer);
 }
 /**
  * Test method for {@link
  * org.apache.tiles.request.jsp.JspPrintWriterAdapter#append(java.lang.CharSequence, int, int)}.
  *
  * @throws IOException If something goes wrong.
  */
 public void testAppendCharSequenceIntInt() throws IOException {
   JspWriter writer = createMock(JspWriter.class);
   CharSequence sequence = createMock(CharSequence.class);
   expect(writer.append(sequence, 0, STRING_LENGTH)).andReturn(writer);
   JspPrintWriterAdapter adapter = new JspPrintWriterAdapter(writer);
   replay(writer);
   assertEquals(adapter, adapter.append(sequence, 0, STRING_LENGTH));
   verify(writer);
 }
 /**
  * Test method for {@link org.apache.tiles.request.jsp.JspPrintWriterAdapter#append(char)}.
  *
  * @throws IOException If something goes wrong.
  */
 public void testAppendCharEx() throws IOException {
   JspWriter writer = createMock(JspWriter.class);
   expect(writer.append('c')).andThrow(new IOException());
   writer.flush();
   JspPrintWriterAdapter adapter = new JspPrintWriterAdapter(writer);
   replay(writer);
   assertEquals(adapter, adapter.append('c'));
   assertTrue(adapter.checkError());
   verify(writer);
 }
 /**
  * Test method for {@link
  * org.apache.tiles.request.jsp.JspPrintWriterAdapter#append(java.lang.CharSequence, int, int)}.
  *
  * @throws IOException If something goes wrong.
  */
 public void testAppendCharSequenceIntIntEx() throws IOException {
   JspWriter writer = createMock(JspWriter.class);
   CharSequence sequence = createMock(CharSequence.class);
   expect(writer.append(sequence, 0, STRING_LENGTH)).andThrow(new IOException());
   writer.flush();
   JspPrintWriterAdapter adapter = new JspPrintWriterAdapter(writer);
   replay(writer);
   assertEquals(adapter, adapter.append(sequence, 0, STRING_LENGTH));
   assertTrue(adapter.checkError());
   verify(writer);
 }
  @Override
  protected int writeTagContent(JspWriter jspWriter, String contextPath) throws JspException {

    try {
      Iterable<Railway> railways = null;
      if (!getCriteria().has(Criteria.RAILWAY)) {
        railways = getService().railways();
      }

      jspWriter.append(render(railways, Criteria.RAILWAY, contextPath).toString());

    } catch (IOException e) {
      throw new JspException(e);
    }

    return SKIP_BODY;
  }
  @Override
  protected int writeTagContent(JspWriter jspWriter, String contextPath) throws JspException {

    try {
      Iterable<Scale> scales = null;
      if (!getCriteria().has(Criteria.SCALE)) {
        scales = getService().scales();
      }

      jspWriter.append(render(scales, Criteria.SCALE, contextPath).toString());

    } catch (IOException e) {
      throw new JspException(e);
    }

    return SKIP_BODY;
  }