2
I am trying to create a component to receive the user profile picture. But for this I need to make the component access the methods within the CDI bean of the page in question. I’m doing something like this:
Creating the component:
<composite:interface displayName="profilePhoto">
<composite:attribute name="mBean" type="br.com.fm.modelo.abstracts.ProfilePhoto" required="true"
shortDescription="Bean que gerencia esta página." />
</composite:interface>
<composite:implementation>
[...cut...]
<p:commandButton action="#{cc.attrs.mBean[fecharFotoDialog]}"/>
[...cut...]
</composite:implementation>
Creating the Bean:
@Named
@ViewScoped
public class CadastroUsuario extends ProfilePhoto implements Serializable {
public void fecharFotoDialog() {
System.out.println("Entrei nesse treco aqui...");
}
}
Calling the component on the primefaces:
<t:profilePhoto mBean="#{cadastroUsuario}"/>
What do I expect to happen? That by clicking on the button that is in the method component fecharFotoDialog()
be called.
Any direction where I’m going wrong?
Grateful,
So it doesn’t work?
action="#{cadastroUsuario.fecharFotoDialog()}"
– Roknauta
@Douglas you mean put that where? In the implementation of Composite or in the <t:profilePhoto component>?
– alacerda
In implementation.
– Roknauta
@Douglas, it doesn’t work. But even so, Composite cannot have the name of Bean hardcoded, it has to receive this at the time of component implementation.
– alacerda
I’ve tried this too: <Composite:attribute name="mbean" required="true" shortDescription="Bean that manages this page."/>
– alacerda
The answers seem simple to this question, but they don’t really work. Nor does an exception appear. You have this example: http://stackoverflow.com/questions/24018539/passing-a-backing-bean-instance-as-parameter-to-composite-component
– alacerda