Get rendered html code in Backing Component from Composite Component

南楼画角 提交于 2019-12-14 04:20:07

问题


How can I get the posted form data in the backing component in the processUpdates method?

@Override
    public void processUpdates(FacesContext context) {
//get here rendered html code
}

Or can I get the posted form data in the decode method?

[Edit]: My goal is to get the posted form data - Not to get the generated html code (Sry I wasn't precisely)


回答1:


It is unclear what you want to achive, yet. I mean, at high level.

UIComponent.decode and processUpdates are medium-level lifecycle APIs which should be overriden when you want to extend the framework.

If you just need to use the framework, you need a managed bean, not a backing component.

Furthermore, generally only components that extend UIInput need to hook in those phases, because they are bound to a value="#{...}" value expression (which in turn refers to a managed bean, in most cases), and need to synchronize those values with the bound expression.

I suspect you are uselessly complicating your life: hooking into medium or low-level APIs is a real pain if you don't have an excellent understanding about how the framework operates.

Anyway, the standard request parameters decode into input component is this:

String clientId = this.getClientId(context);

Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap();

String newValue = requestMap.get(clientId);
if (newValue != null) 
{
    this.setSubmittedValue(newValue);
}

Please, post the full xhtml facelet code (not the composite one, but the facelet using that composite), so I can understand where you want to go and I can try to point you to the right tool to use.



来源:https://stackoverflow.com/questions/44604962/get-rendered-html-code-in-backing-component-from-composite-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!