简体   繁体   English

您可以在JSF Renderer中添加子组件吗?

[英]Can you add a child component while within a JSF Renderer

I would like to add a child component while inside of the encodeBegin 我想在encodeBegin内部添加一个子组件

 public void encodeBegin(FacesContext context,
   UIComponent component)
   throws IOException {
    XspInputText xip = new XspInputText();

  ViewPickList vplComponent = (ViewPickList) component;
  ResponseWriter writer = context.getResponseWriter();
  String viewName = vplComponent.getViewName();
  if (StringUtil.isNotEmpty(viewName)) {
          xip.setId(vplComponent.getId() + "_InputText");
   xip.setValue("Value");
   vplComponent.getChildren().add(xip);
  super.encodeBegin(context, vplComponent); 


  }

This doesn't appear to work, but I am trying to add the child component inside and have it render. 这似乎不起作用,但是我试图在其中添加子组件并使它呈现。 Can anyone suggest a better way of doing this? 谁能建议更好的方法呢?

You should call you newly added components encodeBegin and encodeEnd methods to render them too. 您应该调用新添加的组件encodeBeginencodeEnd方法来渲染它们。

Try this: 尝试这个:

  xip.encodeBegin(context);
  xip.encodeEnd(context);

Also take a look at This link . 另请查看此链接

Please give me feed back if it works or not! 如果有效,请给我反馈!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM