luni, 8 iunie 2015

[OmniFaces utilities 2.0] Write component attributes of the given names


[OmniFaces utilities] The writeAttributes() method writes component attributes of the given names, if it's not empty. Both HTML attribute name and component property name defaults to the given component attribute name.

Method:
Usage:

This is a lightweight version of the Renderers#writeAttributes() that uses a map of component property-HTML attribute names of the attributes to be written. In this case, the provided array of names is used for HTML attribute names and component properties names also.

import org.omnifaces.util.Renderers;
...
String[] names = {"title", "onmouseover", "longdesc"};

@Override
public void encodeBegin(FacesContext context) throws IOException {
 ResponseWriter writer = context.getResponseWriter();
 ...
 writeAttributes(writer, this, names);
}


Niciun comentariu:

Trimiteți un comentariu