JSF call a method and display a modal in particular cases

In my .xhtml file I have a button which calls a method from my ManagedBean. That method should run some tests and if those test are failing I should display a pop-up with an warning or an error. The warning should not affect the future flow, but the error should stop it.

How can I launch a pop up from backend?

Replay

Simply put, you do not launch any pop-ups from back-end. Your backing beans have no understanding of the DOM or the browser. What you can do, however, is saving the state in a backing bean and render a given HTML or JavaScript block based on that state. For this you can use the rendered="#{mybean.myboolean}" attribute in conjunction with a update="elementID" on your button. When clicked, the button will re-render an element with the given ID on the server and inject it into the DOM. If it contains HTML or JS code for a pop-up, then it shows up.

See here for a nice example: Ajax updation and submission using h:commandButton

Category: java Time: 2016-07-31 Views: 69

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.230 (s). 12 q(s)