开发者

richfaces show modalPanel if long page loading time, not showing modalPanel when page load fast

I use modalpanl to prevent user clicking on submit button multiple times like following code. however开发者_运维技巧, when there is a form validation on same page, it brings modal panel out as well. because validation is a very fast process, modal panel got brought out and got cleared in a very short time .like 0.5 sec. it looks like a flash to user and it makes bad user experience. is there anyway to show modalPanel only when it takes more than 1 sec to load a page.

onclick="Richfaces.showModalPanel('InProgress');" oncomplete="Richfaces.hideModalPanel('InProgress');"


It seems that you want to prevent the form from multiple submissions . You can simply disable the submit button using its onclick attribute . In the form validation process , in case of any validation errors , the submit button should enable back .

When the action method of the submit button finishes ,and if the submit button 's rendered attribute does not depend on any Mbean value , you can simply enable back the submit button using its oncomplete attribute . If the submit button 's rendered attribute depends on some MBean 's properties and there are chances that these properties will be changed in action method , then you should reRender the submit button.

For example ,

If the submit button 's rendered attribute does not depend on any Mbean value

<a4j:commandButton id="submitBtn" value="Submit" action="#{MBean.action}" onclick="this.disabled=true" oncomplete="this.disabled=false"/>

If the submit button 's rendered attribute depends on some Mbean value

<a4j:commandButton id="submitBtn" value="Submit" action="#{MBean.action}" onclick="this.disabled=true" rendered="#{MBean.someValue}"  reRender="#{rich:clientId('submitBtn')}"/>

I think this approach is more straightforward , easier to understand and maintainable than using the ModalPanel approach to block the form from multiple submissions .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜