Pracede
Pracede

Reputation: 4361

JSF : How to create a modal link with onclick action?

I don't know JSF and i have to modify a JSF web page. I must add the following :

<a href="" data-toggle="modal" id="#mymodal" onclick="openModal()">
                                                     Link   
                                                    </a>

But in JSF i don't know how to write it. Could you help me please ?

Upvotes: 1

Views: 1406

Answers (1)

fxrobin
fxrobin

Reputation: 652

The cool thing about a JSF page, is that it supports plain HTML/CSS/JavaScript as well.

You can place any of them in your page and will be sent to the browser, but they will not be considered as JSF components.

If your project uses Primefaces, you can open a modal dialog on a button or or link easily with p:dialog component. See : https://www.primefaces.org/showcase/ui/overlay/dialog/basic.xhtml. This way the dialog is part of the JSF component tree.

If not, you can still embed JQuery UI by yourself with referring to a CDN or import it with h:outputScript and use the JQuery Dialog component.

Primefaces uses Jquery UI indeed.

Upvotes: 1

Related Questions