Hello, It seems i am not clear on my previous question about managed bean. So, i am posting it again in a more systematic manner.
I have one page :-
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<ui:insert name="head">
</ui:insert>
<br/><br/>
<h:inputText value="#{MasterBean.laala}"/>
<br/><br/>
<ui:insert name="content">
</ui:insert>
</h:body>
</html>
This is it's bean :-
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="MasterBean")
@ViewScoped
public class MasterBean {
private String laala;
public String getLaala() {
return laala;
}
public void setLaala(String laala) {
this.laala = laala;
}
public MasterBean() {
}
}
This is data.xhtml which uses master.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<ui:composition template="master.xhtml">
<ui:define name="head">
laala
</ui:define>
<h:outputText value="#{pageBean.content}"/>
<ui:define name="content">
<h:commandButton actionListener="#{pageBean.speakHello}"/>
</ui:define>>
</ui:composition>
</h:body>
</html>
This is it's bean :-
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="pageBean")
@ViewScoped
public class pageBean {
private String content;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public void speakHello(){
//how do i get value of laaala here which is in MasterBean???
content = ??? + " Hello friend";
}
public pageBean() {
}
}
Please fill in the blank where ??? is marked in speakHello(). How do i get value of other bean in this bean? I think this time i am very clear. Please BalusC, Bozho and other java experts, let me know if, still i am not clear.
Thanks in advance :) This time i surely expect a answer :)