如何从另一个屏幕转到新屏幕时调用mehtod。我想从menu中调用屏幕的方法onload.but它不应该在同一屏幕上调用加载方法.. 我每次来自另一个屏幕时都会调用清除字段方法但是在同一屏幕上如果它通过搜索按钮加载则会调用清除方法。
<script type="text/javascript">
window.onbeforeunload = function()
{
exitFunc();
alert("test 1");
}
</script>
<h:form id="exitForm"> -->
<p:remoteCommand name="exitFunc" actionListener="#{letterCancellationManager.clearMaster}" />
</h:form>
<f:metadata>
<f:event type="preRenderView" listener="#{letterCancellationManager.clearMaster}"/>
</f:metadata>
我已经尝试了这个,但每次加载时都会清除字段,但我想清除来自另一个屏幕的字段。请回复
答案 0 :(得分:0)
我用这个
解决了这个问题清除缓存 经理支持bean:
private String id; //its setter getters
________________________________________________________________________________
//clear method
public void clearMaster()
{
try
{
if(id!=null && id.equals("1"))
{
byRfq="";
byNsn="";
byDoc="";
byLetterNo="";
byLetterDate=null;
byEmailDate=null;
}
}catch(Exception ee){}
}
________________________________________________________________________________
//write inside the method which is calling default on master
try{
int id = Integer.valueOf(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id"));
this.id=id+"";
}catch(Exception ee){}
id="";
________________________________________________________________________________
inside UI JSF VIEW of screen
<f:view >
<f:metadata>
<f:viewParam name="id" value="#{letterCancellationManager.id}" />
<f:event type="preRenderView" listener="#{letterCancellationManager.clearMaster}"/>
</f:metadata>