html - JSF inserts tag automatically, disturbing the order on page
问题描述
I have a very basic JSF XHMTL page with the following content
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Pregled oglasa</title>
</h:head>
<h:body>
<h:outputText value="#{oglasBean.naziv}" />
<br />
<br />
<h:outputText value="#{oglasBean.imeAutora}" />
<br />
<h:outputText value="#{oglasBean.prezimeAutora}" />
<br />
</h:body>
</html>
Here's the piece of code that sets up these variables:
public String pregledOglasa() {
Map<String, String> reqMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
int idOglasa = Integer.parseInt(reqMap.get("oglas_id"));
for (Oglas oglas : aktivniOglasi) {
if (oglas.getIdOglasa() == idOglasa) {
this.setIdOglasa(idOglasa);
this.setNaziv(oglas.getNaziv());
this.setTekstOglasa(oglas.getTekstOglasa());
this.setImeAutora(oglas.getImeAutora());
this.setPrezimeAutora(oglas.getPrezimeAutora());
this.setLokacijaDo(oglas.getLokacijaDo());
}
}
return "/korisnik/pregledOglasa?faces-redirect=true";
}
What happens here is that "oglasBean.naziv", once when you open the page, comes after "oglasBean.imeAutora" and "oglasBean.prezimeAutora". Inspecting the code revealed that, for some reason, "oglasBean.naziv" is wrapped in pre tag and shows up the last, i.e. after "oglasBean.imeAutora" and "oglasBean.prezimeAutora":
In example given, "title 2" is meant to be above "John" and "Johnson".
Googling for this does't show anything similar, so it seems I am stuck here with a weird problem.
Even if I change "#{oglasBean.naziv}"
to "#{oglasBean.imeAutora}"
the problem remains the same, like JSF just takes whatever is first on the page and wrappes it in pre.
解决方案
推荐阅读
- boto3 - Boto Stubber SQS
- performance - Spock 性能问题
- python - Yubikey 5 NFC 使用 ACR122U 在 Python 中生成 OTP
- css - 如何使用 React 中的样式在特定 div 中设置线性渐变和背景图像
- javascript - cordova/phonegap 屏幕缺口检测(适用于所有手机,不仅适用于 iPhone X)
- mysql - 如何根据 mySQL 中已存在的列自动将值插入到我创建的新列中
- python - 我无法理解这行代码的作用?
- python - Anaconda2 ImportError:没有名为 matplotlib.pylab 的模块
- python - 张量流增量嵌套 variable_scope
- android - Kotlin - RecyclerView-android.view.InflateException 项中的 BottomNavigation:二进制 XML 文件第 91 行:膨胀类错误