I am basically a .net developer and very new to jsf, so it may be a very basic question and its answer may be very obvious, sorry for that.
I have developed a jsf application. where I have a form with personal data and a link button for some other functionality. When personal data is filled and displayed on jsf, I click on that link button, which calls some bean functionality. but my previous data of ‘personal data’ is loss. OR I can say that on postback data of my jsf page losts/resets.
Edit: Here goes my jsf and bean
<f:view>
<h:form>
<h:inputText value="#{myBean.name}"/>
<h:commandButton action="#{myBean.getInfo}/>
<h:outputText value="#{myBean.fullName}"/>
<h:outputText value="#{myBean.contactNo}"/>
<h:commandLink action="#{myBean.changeContactNo"}/>
</h:form>
</f:view>
and myBean:
public class myBean
{
private String name;
private String fullName;
private String contactNo;
public myBean()
{
}
public String getInfo()
{
String endName = getname();
fullName = "Prof"+ endName;
contactNo = "12345";
}
public String changeContactNo()
{
contactNo = "999999";
}
}
Now when I click on command button it sets the full name and contact no.
But when I click on Link button it should only change the contact no. but “fullName” value
of outputText is lost.
You probably need to look for Bean Scopes currently you are probably using request scoped beans try switching to view scoped or session scoped
Edit: And you should have corresponding data fields related with html form elements in your backing bean with getters and setters.