Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I make a Label Provider using JSF-1.2?
    primarykey
    data
    text
    <p>I want to automatically set the labels attributes for the UIInput components in my pages, to the HtmlOutputLabel components I already put, like the PrimeFaces developer did: <a href="http://cagataycivici.wordpress.com/2011/02/11/label-provider-for-jsf-input-components/" rel="nofollow">http://cagataycivici.wordpress.com/2011/02/11/label-provider-for-jsf-input-components/</a> Only he did it using System Events, a feature available only in JSF-2.0, and my application is in JSF 1.2.</p> <p>Is it possible to do it using JSF-1.2, with maybe a Phase Listener? What would be the drawbacks?</p> <p>Thanks in advance!</p> <p><strong>UPDATE:</strong> This is what my attempt with a Phase Listener looks until now:</p> <pre><code>@Override public void beforePhase(PhaseEvent event) { System.out.println("REGISTERING Label Provider"); FacesContext context = event.getFacesContext(); List&lt;UIComponent&gt; components = context.getViewRoot().getChildren(); for (UIComponent uiComponent : components) { if (uiComponent instanceof HtmlOutputLabel) { HtmlOutputLabel outputLabel = (HtmlOutputLabel) uiComponent; System.out.println("CONFIGURING LABEL: " + outputLabel.getId()); UIComponent target = outputLabel.findComponent(outputLabel .getFor()); if (target != null) { target.getAttributes().put("label", outputLabel.getValue()); } } } } @Override public PhaseId getPhaseId() { // Only listen during the render response phase. return PhaseId.RENDER_RESPONSE; } </code></pre> <p>When I access the view, it never prints the section "CONFIGURING LABEL". What would be the right test to verify if a uiComponent is a HtmlOutputLabel? Or what am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload