5分钟后执行一个方法,忽略jsp中的重载

时间:2013-10-24 20:04:06

标签: java jsp liferay-6

嗨我在jsp中有一些代码,我正在使用liferay。 我有下一个代码:

<aui:form>

<aui:input label="user" name="user" type="text"
    showRequiredLabel="<%=false%>" value="<%=correo%>">
    <aui:validator name="email" />
    <aui:validator name="required" />
</aui:input>
<br>

<aui:input label="password" name="password" type="password"
    showRequiredLabel="<%=false%>" value="<%=password%>">
    <aui:validator name="required" />
</aui:input>
<br>`<aui:button-row>
    <aui:button type="submit" value="update"  />
    </aui:button-row>
</aui:form>

`

    <%ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
    ExchangeCredentials credentials = new WebCredentials(user, pass);
    service.setCredentials(credentials);
    service.setUrl(new java.net.URI(server));
    service.setTraceEnabled(true);  
    CalendarFolder cf=CalendarFolder.bind(service, WellKnownFolderName.Calendar);
    FindItemsResults<Appointment> findResults = cf.findAppointments(
            new CalendarView(startDate, endDate));  

    for (Appointment appt : findResults.getItems())
    {
       appt.load();                
       appt.getSubject().toString();
       appt.getStart();
       appt.getEnd();
       appt.getLocation();          
}   
%>`

问题是当我刷新页面执行“某些代码行”并且速度太慢时,我想在5分钟后执行这个“一些代码行”,无论页面是否刷新了一些想法? 我想每五分钟执行一次,而不是每次刷新

1 个答案:

答案 0 :(得分:0)

一种解决方案是对五分钟后要执行的部分使用ajax调用。我希望这有帮助

<script>
//300000 = 5 minues
setInterval("yourAjaxCall()",300000);
function yourAjaxCall(){...}
</script>