Get rendered html code in Backing Component from C

2019-07-17 07:32发布

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条回答
姐就是有狂的资本
2楼-- · 2019-07-17 08:13

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.

查看更多
登录 后发表回答