gpt4 book ai didi

com.github.bordertech.wcomponents.WText类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 18:07:05 28 4
gpt4 key购买 nike

本文整理了Java中com.github.bordertech.wcomponents.WText类的一些代码示例,展示了WText类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WText类的具体详情如下:
包路径:com.github.bordertech.wcomponents.WText
类名称:WText

WText介绍

[英]WText is used to render some basic/raw text.
[中]WText用于呈现一些基本/原始文本。

代码示例

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

/**
   * @param margin the margin to include on the panel.
   * @return the panel with a margin.
   */
  private WPanel createPanel(final Margin margin) {
    WText text = new WText(DUMMY_TEXT);
    text.setEncodeText(false);

    WPanel panel = new WPanel(WPanel.Type.BOX);
    panel.add(text);
    panel.setMargin(margin);
    return panel;
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
  public void testSanitizeOnOutput() {
    WText text = new WText("<form>content</form>");
    text.setSanitizeOnOutput(true);
    text.setEncodeText(false);
    Assert.assertEquals("Expect output to be sanitized", "content", text.getText());
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

/**
 * Override of preparePaintComponent to set the dynamic (user specific) text.
 *
 * @param request the request being responded to.
 */
@Override
public void preparePaintComponent(final Request request) {
  String dateStr = "The current date is " + new Date();
  dynamicText.setText(dateStr);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * @return a String representation of this component, for debugging purposes.
 */
@Override
public String toString() {
  String text = getText();
  text = text == null ? "null" : ('"' + text + '"');
  return toString(text);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

@Override
  public void execute(final ActionEvent event) {
    ajaxContent.setText(before.equals(ajaxContent.getText()) ? after : before);
  }
});

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

/**
   * Creates a SimpleListRenderer.
   */
  public SimpleListRenderer() {
    WText name = new WText();
    WText type = new WText();
    WText thing = new WText();
    name.setBeanProperty("name");
    type.setBeanProperty("type");
    thing.setBeanProperty("thing");
    WFieldLayout fields = new WFieldLayout();
    fields.addField("Name", name);
    fields.addField("Type", type);
    fields.addField("Thing", thing);
    add(fields);
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-addons-table

/**
 * @param label the column label
 */
public AbstractTableColumn(final String label) {
  this(null, label, new WText(), null);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

/**
 * applySettings creates the WCollapsible, and loads it into the container.
 */
private void applySettings() {
  // reset the container.
  container.reset();
  // create the new collapsible.
  WText component1 = new WText("Here is some text that is collapsible via ajax.");
  WCollapsible collapsible1 = new WCollapsible(component1, "Collapsible",
      (CollapsibleMode) rbCollapsibleSelect.getSelected());
  collapsible1.setCollapsed(cbCollapsed.isSelected());
  collapsible1.setVisible(cbVisible.isSelected());
  if (collapsible1.getMode() == CollapsibleMode.DYNAMIC) {
    component1.setText(component1.getText() + "\u00a0Generated on " + new Date());
  }
  if (drpHeadingLevels.getSelected() != null) {
    collapsible1.setHeadingLevel((HeadingLevel) drpHeadingLevels.getSelected());
  }
  // add the new collapsible to the container.
  container.add(collapsible1);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testGetText() {
  WText wtf = new WText();
  String defaultText = "Dflt";
  String myText = "MyText";
  wtf.setText(defaultText);
  Assert.assertEquals("Incorrect default text", defaultText, wtf.getText());
  // Set test for a users session
  wtf.setLocked(true);
  setActiveContext(createUIContext());
  wtf.setText(myText);
  Assert.assertEquals("Should have session text", myText, wtf.getText());
  resetContext();
  Assert.assertEquals("Should have default text", defaultText, wtf.getText());
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testNoSanitizeOnOutput() {
  String input = "<form>content</form>";
  WText text = new WText(input);
  text.setEncodeText(false);
  Assert.assertEquals("Expect output to not be sanitized", input, text.getText());
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testEncodeText() throws IOException, SAXException, XpathException {
  String value = "T1<b>T2</b>T3";
  String encoded = WebUtilities.encode(value);
  WText text = new WText();
  text.setText(value);
  // Encoded (default)
  String xml = toXHtml(text);
  Assert.assertTrue("XML should have encoded text", xml.contains(encoded));
  // Not encoded
  text.setEncodeText(false);
  xml = toXHtml(text);
  Assert.assertTrue("XML should have not encoded text", xml.contains(value));
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

beanBoundText.setBeanProperty("beanAttribute");
beanProviderBoundText.setBeanProperty("innerBean.innerAttribute");
add(button2);
beanProviderBoundText.setBeanProvider(new ExampleBeanProvider());
add(new WText("&bull;"));
add(new WHeading(HeadingLevel.H2, "Unencoded text containing a HTML character entity"));
WText unescapedWithEntity = new WText("&bull;");
unescapedWithEntity.setEncodeText(false);
add(unescapedWithEntity);

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testIsDefaultState() {
  String defaultText = "Dflt";
  String myText = "MyText";
  WText wtf = new WText(defaultText);
  wtf.setLocked(true);
  setActiveContext(createUIContext());
  Assert.assertTrue("Should be in default state by default", wtf.isDefaultState());
  wtf.setText(myText);
  Assert.assertFalse("Should not be in default state after setting different text", wtf.
      isDefaultState());
  wtf.setText(defaultText);
  Assert.assertTrue("Should be in default state after setting text to default text", wtf.
      isDefaultState());
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testConstructor1() {
  WText content = new WText();
  WFigure figure = new WFigure(content, "label");
  WText txt = (WText) figure.getDecoratedLabel().getBody();
  Assert.assertEquals("Constructor - Incorrect label", "label", txt.getText());
  Assert.assertSame("Constructor - Incorrect content", content, figure.getContent());
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * test remove - child from shared list.
 */
@Test
public void testRemoveCommon() {
  AbstractWComponent comp = new MockContainer();
  WText text1 = new WText("XYZ");
  WText text2 = new WText("ABC");
  comp.add(text1);
  comp.add(text2);
  comp.remove(text1); // from shared list
  Assert.assertNull("shared should not contain text1", text1.getParent());
  Assert.assertSame("shared should contain text2", text2, comp.getChildAt(0));
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
  WText text = new WText();
  text.setText(getInvalidCharSequence());
  assertSafeContent(text);
  text.setText(getMaliciousContent());
  assertSafeContent(text);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

/**
   * {@inheritDoc}
   */
  @Override
  public String getText() {
    return super.getText() + " generated at: " + new Date();
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

/**
   * Construct example.
   */
  public WSessionExample() {
    WMessages messages = new WMessages(true);
    messages
        .info("If \"ui:session\" is supported by the theme, wait 180 seconds to see a warning message and then a session expired message.");
    add(messages);

    WText txtSession = new WText() {
      @Override
      public String getText() {
        return "<ui:session timeout=\"180\" />";
      }
    };
    txtSession.setEncodeText(false);

    add(txtSession);
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

/**
 * Creates a WDropdownSubmitOnChangeExample.
 */
public WDropdownSubmitOnChangeExample() {
  actMessage.setEncodeText(false);
  add(new ExplanatoryText("Any form control component which is not a WButton will show a visible warning in its label if its "
      + "submitOnChange property is set true."));
  WFieldLayout flay = new WFieldLayout();
  add(flay);
  flay.setLabelWidth(25);
  flay.setMargin(new Margin(null, null, Size.LARGE, null));
  flay.addField("State", stateSelector).getLabel().setHint("Selecting a state will update the available regions.");
  flay.addField("Region", regionSelector);
  // Used to test control of visibility as part of submit on change.
  add(actMessage);
  actMessage.setVisible(false);
  stateSelector.setOptions(new String[]{null, STATE_ACT, STATE_NSW, STATE_VIC});
  //This is the flag which causes accessibility problems. It may be removed completely in future versions of WComponents.
  //you should use AJAX instead
  stateSelector.setSubmitOnChange(true);
  stateSelector.setActionOnChange(new Action() {
    @Override
    public void execute(final ActionEvent event) {
      updateRegion();
      regionSelector.resetData();
    }
  });
  regionSelector.setSubmitOnChange(true);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
   * Paints the given WText.
   *
   * @param component the WText to paint.
   * @param renderContext the RenderContext to paint to.
   */
  @Override
  public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WText text = (WText) component;
    XmlStringBuilder xml = renderContext.getWriter();

    String textString = text.getText();

    if (textString != null) {
      if (text.isEncodeText()) {
        xml.print(WebUtilities.encode(textString));
      } else {
        // If we are outputting unencoded content it must be XML valid.
        xml.print(HtmlToXMLUtil.unescapeToXML(textString));
      }
    }
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com