dependency injection - JSF 2.0 + Primefaces richtext editor -
<p:editor value="#{editorbean.value}" widgetvar="editor" width="686" height="390" language="en" align="center"> </p:editor> following rich-text editor bean picked primefaces
@managedbean(name = "editorbean") @sessionscoped public class editorbean { private static final string managed_bean_name = "editorbean"; private string value; public static editorbean getcurrentinstance() { return (editorbean) facescontext.getcurrentinstance() .getexternalcontext().getrequestmap().get(managed_bean_name); } public void setvalue(string value) { this.value = value; } public string getvalue() { return value; } } apart have bean a. have method inside populates html table. want when user opens editor, should pre-populated html table data , of course changes should reflected (string: value). therefore, can trying tie both values together. think needs done di somehow not working. if can guide or quote example, helpful.
one way rewrite getvalue() method pick value bean a. , yes, reference bean should come di:
//injecting reference @managedpropery(value="#{a}") //or whatever name of bean private beana; public void setbeana(a beana) { this.beana = beana; } or, cdi, just:
@inject private beana finally, getvalue method
public string getvalue() { return beana.getvalue() }
Comments
Post a Comment