JSF插入<pre> tag automatically, disturbing the order on page

时间:2018-06-18 11:36:41

标签: html jsf xhtml-transitional

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":

enter image description here

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.

1 个答案:

答案 0 :(得分:0)

好吧,这个似乎比我想象的更快地解决了,实际上我可以想到任何愚蠢的东西。我尝试将所有内容包装在

noteSlectionnee

尝试添加 div 标记。它没用。然后我只是尝试了简单的 div ,瞧,现在一切似乎都在顺序,没有额外的标签或其他:

enter image description here

如果这是某种默认的JSF行为或者可能是故障,我还是会徘徊?