How to create multiple anchor tag and fetch href value from database dynamically in JSF? [duplicate] - jsf

This question already has answers here:
Iterate through List<String> using JSF 2
(1 answer)
What URL to use to link / navigate to other JSF pages
(1 answer)
Using JSF EL in a plain HTML attribute
(3 answers)
Closed 27 days ago.
I want to create a dynamic anchor tag. Let's say I have a database and I want to use them.
Example:
Before
Page 1
Page 2
Page 3
It should be something like this
--After--
{Value from database}
#{linkOpsBean.srcNameList[0]}

Here's what worked for me!
<ui:repeat value="#{Bean.srcNameList}" var="value">
<li><a class="dropdown-item" href="#{value}">#{value}</a></li>
</ui:repeat>

Related

How can I add JSF code to xhtml in the attribute id? [duplicate]

This question already has answers here:
How to dynamically generate id in dataTable using ui:repeat tag
(4 answers)
How to use EL with <ui:repeat var> in id attribute of a JSF component
(1 answer)
Closed 6 years ago.
I am working with JSF 2.2 and I would like use JSF variables in the id attribute for to send individuals petitions for each list's element.
For example:
<ui:repeat value="#{bean.numbers}" var="number">
<h:inputText id="text#{number}"/>
</ui:repeat>
Thank you

Using rendered with JSF [duplicate]

This question already has an answer here:
Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?
(1 answer)
Closed 7 years ago.
How does rendered work? It hides h:form content completely and does not show it if expression.list is not empty.
<h:form id="stackForm" rendered="#{not empty expression.list}">
<p:orderList id="stack" value="#{expression.list}"...
...
It doesn't hide it - it doesn't render it at all, if rendered condition evaluates to false. In your case, if #{expression.list} is empty, form will not be rendered. Or, when rendered is translated to plain English, read it as Render the form if expression.list is not empty.

JSF components facets [duplicate]

This question already has an answer here:
List of JSF / Tobago Facets?
(1 answer)
Closed 9 years ago.
How can I find out which facets are available for a JSF component?
For example: I know that for the <h:column> I can use <f:facet name="header">, because I have seen it in many examples.
But let's say I didn't know that header facet existed for column.
How would I find it out? Is there some place where available facets are declared? Or is there a standard place in the documentation where facets are listed?
One way:
Try autocomplete in your IDE
after the " in <f:facet name=" just press CTRL + SPACE

How to display html code which is load from db in jsf screen? [duplicate]

This question already has an answer here:
Component to inject and interpret String with HTML code into JSF page
(1 answer)
Closed 6 years ago.
I have html code in one column. Loaded html code to one bean.
My question is how to display this html code using jsf tags.
You can use a <h:outputText> component, and set escape="false".

Jsf control that format text with html tags [duplicate]

This question already has an answer here:
Component to inject and interpret String with HTML code into JSF page
(1 answer)
Closed 6 years ago.
Good morning all.
Is there any jsf control that escapes the html tags?
Imagine that i have the following string in resources:
text.String=lalala<br/>lelele
and i want to print it on Xhtml file with a simple control like:
<h:outputText value="#{messages['text.String']}" />
how do i get the result formatted with the html <br/> tag?
Result should be:
lalala
lelele
instead of:
lalala<br/>lelele
Thanks
the outputText control has an 'escape' property which controls that behaviour.
See here (outputText reference).
So basically:
<h:outputText escape="false" value="#{messages['text.String']}" />
should do the job.

Resources