Understanding f:attribute and f:param

Lets see!

This is the view I have, foo.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!--
    User: Koray Tugay (koray@tugay.biz)
    Date: 7/22/2016
    Time: 7:58 PM
-->
 
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
    <h:head>
        <title>Foo</title>
    </h:head>
    <h:body>
        <h:form id="fooForm"
                prependId="false">
            <h:inputText value="#{foo.foo}">
                <f:attribute name="attributeName" value="attributeValue"/>
                <f:param name="paramOne" value="paramOneValue"/>
                <f:param name="paramTwo" value="paramTwoValue"/>
                <f:param name="paramTwo" value="paramTwoOtherValue"/>
            </h:inputText>
            <br/>
            <h:commandButton value="Submit"/>
        </h:form>
        <h:outputText id="outputText" value="#{foo.foo}"/>
    </h:body>
</f:view>
</html>

And here is Foo.java
package biz.tugay;
 
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
/**
 * User: Koray Tugay (koray@tugay.biz)
 * Date: 7/22/2016
 * Time: 7:57 PM
 */
 
@ManagedBean
@SessionScoped
public class Foo {
 
    private String foo;
 
    public String getFoo() {
        final FacesContext currentInstance = FacesContext.getCurrentInstance();
        final UIViewRoot viewRoot = currentInstance.getViewRoot();
        final UIComponent htmlBody = viewRoot.getChildren().get(3);
        final UIComponent htmlForm = htmlBody.getChildren().get(0);
        final UIComponent htmlInputText = htmlForm.getChildren().get(0);
        final Map<String, Object> attrMap = htmlInputText.getAttributes();
        final Set<String> htmlInputTextAttributeKeys = attrMap.keySet();
        for (String key : htmlInputTextAttributeKeys) {
            System.out.println("Attribute key: " + key +
                    ", Attribute value: " + attrMap.get(key));
        }
        final List<UIComponent> prmList = htmlInputText.getChildren();
        for (UIComponent uiComponent : prmList) {
            final UIParameter prm = (UIParameter) uiComponent;
            System.out.println("Parameter name: " + prm.getName()
                    + ", Parameter value: " + prm.getValue());
        }
        return foo;
    }
 
    public void setFoo(String foo) {
        this.foo = foo;
    }
}

What I will see on the console is:
Attribute key: attributeName, Attribute value: attributeValue
Parameter name: paramOne, Parameter value: paramOneValue
Parameter name: paramTwo, Parameter value: paramTwoValue
Parameter name: paramTwo, Parameter value: paramTwoOtherValue

And a few notes:
Any component can store arbitrary name/value pairs in its attribute map. You can set an attribute in a page and later retrieve it programatically.

The f:param tag also lets you define a name/value pair, but the value is placed in a separate child component. Also, the child components form a list, not a map. You use f:param if you need to supply a number of values with the same name (or no name at all).