Hi
And can you please comment on this issue raised in the earlier email?
On the email of CodeGeneration?
One fast example is this. Please pay attention on the yellow marks:
abstract class AbstractBuffer extends UIComponentBase
{
protected abstract String getLocalInto();
public abstract void setInto(String into);
void fill(String content, FacesContext facesContext){
ValueExpression intoVB;
if (getLocalInto() == null) {
intoVB = getValueExpression("into");
setInto(intoVB.getExpressionString());
} else {
intoVB = facesContext.getApplication().
getExpressionFactory().createValueExpression(
facesContext.getELContext(), getLocalInto(),
Object.class );
}
intoVB.setValue(facesContext.getELContext(), content);
}
}
public class Buffer extends AbstractBuffer
{
static public final String COMPONENT_FAMILY =
"javax.faces.Data";
static public final String COMPONENT_TYPE =
"org.apache.myfaces.Buffer";
/**
* Construct an instance of the Buffer.
*/
public Buffer()
{
setRendererType("org.apache.myfaces.Buffer");
}
// Property: into
private String _into;
final protected String getLocalInto()
{
return _into;
}
/**
* Gets EL variable for save the components output inside this component
* <p>
* This is a required property on the component.
* </p>
*
* @return the new into value
*/
public String getInto()
{
if (_into != null)
{
return _into;
}
ValueExpression expression = getValueExpression("into");
if (expression != null)
{
return (String)expression.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Sets EL variable for save the components output inside this component
* <p>
* This is a required property on the component.
*
* @param into the new into value
*/
public void setInto(String into)
{
this._into = into;
}
@Override
public Object saveState(FacesContext facesContext)
{
Object[] values = new Object[2];
values[0] = super.saveState(facesContext);
values[1] = _into;
return values;
}
@Override
public void restoreState(FacesContext facesContext, Object state)
{
Object[] values = (Object[])state;
super.restoreState(facesContext,values[0]);
_into = (String)values[1];
}
@Override
public String getFamily()
{
return COMPONENT_FAMILY;
}
}
For one side, I use the generator to create a protected final method to
access the local or inner value. And I make the method available through
abstract methods, defined on the hand written class. The property is defined
on generated class, so reflection code not fail if the base class is package
scope.
regards
Leonardo Uribe