webfirmframework for Java Experts

Normal tag attribute

Attributes which don't capture events are considered as normal tag attributes, eg:- Name, Id, ClassAttribute, Value etc...

All tag attributes will have some common methods like setValue and getValue or getAttributeValue depending on the context. Let's see some examples

Input input = new Input(null);
Value value = new Value("");
input.addAttributes(value);

//prints <input value="">
System.out.println(input.toHtmlString());

value.setValue("webfirmframework");

//prints <input value="webfirmframework">
System.out.println(input.toHtmlString());

//prints webfirmframework
System.out.println(value.getValue());

AbstractAttribute valueAttr = value;

//prints webfirmframework
System.out.println(valueAttr.getAttributeValue());
				

setValue(boolean updateClient, String value)

Some attributes also contain setValue(boolean updateClient, String value) method (since wffweb-2.1.15) which excludes the value syncing in client browser page and it's valid only if there is a client browser page otherwise it works just like setValue. Eg:- Value#setValue(boolean updateClient, String value)
Use case:- Consider <input type="text" value=""> tag in the browser page. The value of the value attribute in the browser page changes whenever the user enters some value the text field. Sometimes we may need to keep the same value state in the server side Value object by OnChange event attribute. In such cases if we are calling value.setValue(String value) method it will again synch the value to client browser page and it's not required in this particular case so we can use value.setValue(boolean clientUpdate, String value) method. eg:- value.setValue(false, enteredValue).
value.setValue(boolean clientUpdate, String value) may be useful to build stateful tags.
Eg:- Its usage is similar to Input tag.

getAttributeValue is a common method in all attributes which returns the string representation of the attribute value.
Based on the relevant context, the attribute will have needful feature methods in it.