Sample VariableResolver


Code 1 - VariableResolver Java class

package com.lugs.jsf;

import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.VariableResolver;

public class ExampleVariableResolver extends VariableResolver {

	private final VariableResolver delegate;

	public ExampleVariableResolver(VariableResolver resolver) {
		delegate = resolver;
	}

	@Override
	public Object resolveVariable(FacesContext context, String name) throws EvaluationException {
		if ("showRow".equals(name)) {
			return true;
		}
		return delegate.resolveVariable(context, name);
	}

}

Code 2 - add into faces-config.xml
<!-- Variable Resolver -->
  <application>
    <variable-resolver>com.lugs.jsf.ExampleVariableResolver</variable-resolver>
  </application>

Code 3 - XSP Markup
<xp:repeat id="repeat1" rows="50000" indexVar="count" var="user"
	value="#{view1}">
		<xp:text
		value="Entry number #{count} is #{user.FirstName} #{user.LastName} 
		whose email address is #{user.EMail} and he/she lives in #{user.City}, #{user.State}"
		rendered="#{showRow}">
		</xp:text>
		<br />
</xp:repeat>
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...