Skip to Content
0
Former Member
Nov 08, 2012 at 07:43 AM

data loss from viewhandler to view

41 Views

Hi Experts,

I have a view component having a button in it, on clicking the button i call the method "createAppmnt" from the viewhandler, which in turn calls the custom RFC from CRM and brings on some data(for testing i am only exporting a string). The data is reaching to the createAppmnt method without any issues. But when i try to access this data in my view component, it doesn't return me anything.

zdlsView.xhtml

<cc:interface componentType="sap.wec.ViewComponent" />
<cc:implementation>

<wec:form id="zapp">
<wec:outputText id="otCustomerService" rendered="true" value="Test"/>
<wec:inputDate styleClass="fw-form-gridcol3" id="iSPWD1" value="#{cc.vch.date}"/>

<wec:commandButton id="appButton"

value="Bring Time Slots"

title="Bring Time Slots"

render="true"

action="#{cc.vch.createAppmnt}">

</wec:commandButton>

<wec:selectOneRadio id="zradio1"

immediate="true" value="Available Time Slots">
<wec:outputText id="zotCustomerService1" rendered="true" value="#{cc.vch.time}"/>
<f:selectItem itemValue="#{cc.vch.time}" />

</wec:selectOneRadio>

</wec:form>
</cc:implementation>



ZApptViewHandlerImpl


private ZCustomBean custBean;
private ZCustomManager custManager;
private Date date;
FacesContext facesContext;
HttpSession session;
ZAppt zapp;
private String time;

@Override
public String createAppmnt() {
try {
DateFormat formatter;
formatter = new SimpleDateFormat("dd-MM-yy");
String zdate = formatter.format(getDate());
zapp = (ZAppt)custBean.createApp(zdate);
custBean.setApp(zapp);
time = zapp.getTime();
custBean.setTime(time);
facesContext = FacesContext.getCurrentInstance();
session = (HttpSession) facesContext.getExternalContext().getSession(false);
session.setAttribute("Time", time);
setTime(time);
}
catch (Exception e) {
}
return "success";
}

public String getTime() {
return time;
}

public void setTime(String time) {

this.time = time;

}

Even "facesContext = FacesContext.getCurrentInstance();" gives me null if i try to access it from any other method than createAppmnt.

It would be great if you can also help me on how to set the data in session and recieve it in view.



Regards