el

JSP and scriptlets

心已入冬 提交于 2019-12-08 19:34:00
问题 I know that using scriptlets are considered taboo nowadays. Its okay and I will agree to the Top Star's words (as I am just a novice in Java at the moment). What I have heard so far is, its to make the designers life easier. But I wonder, if it has anything to do with performance of JSP pages. On the other hand, if its just for "making designers life easier", what do you guys think about using scriptlets in a situation where Java developer do both the work ? If scriptlets are bad in all

<c:if> not working for comparing characters [duplicate]

限于喜欢 提交于 2019-12-08 18:56:58
问题 This question already has an answer here : How to compare a char property in EL (1 answer) Closed 3 years ago . <c:if> is not working for comparing characters.The code is inside a table.Here is the code <c:if test="${record.type eq 'U' }">Planned</c:if> When I use this code inside the table,the table content is not displayed.Please help! 回答1: Issue is EL supports both double and single quoted Strings. So 'U' is taken as String , not char . To resolve the issue, you can use charAt(0) method on

Passing parameters to a method in h:outputtext tag

核能气质少年 提交于 2019-12-08 17:00:45
问题 I would like to display a text in jsf screen by passing an attribute to a method implemented in backing bean. I have to pass a dynamic value as an attribute. I tried the below but it seems to be an incorrect syntax - <h:outputText value="#{getValue(#{item.product}).component.address}" /> 回答1: Apart from the syntax error (you can never nest EL expressions like as #{#{}} ), the following is valid in EL 2.2 which is in turn part of Servlet 3.0 / Java EE 6: <h:outputText value="#{bean.getValue

javax.el.PropretyNotWritableException: The class Article does not have a writable property 'id'

浪尽此生 提交于 2019-12-08 16:24:55
问题 I have an Article DTO (Article.java; code excerpts) public class Article { private int id; public Article() { this.id = 0; } public Integer getId() { return id; } public void setId(int id) { this.id = id; } I got a view template for editing the article (edit_article.xhtml; code excerpts): <h:form id="article_form"> <p:messages id="messages"/> <h:panelGrid columns="2"> <h:outputText value="" /> <h:inputHidden id="articleId" value="#{hqArticleView.article.id}" converter="javax.faces.Integer" />

Comparing strings in EL [duplicate]

江枫思渺然 提交于 2019-12-08 15:27:18
问题 This question already has answers here : How to compare two object variables in EL expression language? (2 answers) Closed 3 years ago . I'm giving a User object to JSP and want to compare an attribute of the user with a given String. What I'm doing right now is the following: <input type="radio" name="lang" value="ger" <c:if test="${user.comLanguage.equals("ger")}">checked="yes"</c:if>/>German</br> But all I get is the following Exception: org.apache.jasper.JasperException: /WEB-INF/jsp

EL equivalent of <%= object.method(parameter) %> in WAS 8?

假如想象 提交于 2019-12-08 13:06:01
问题 The documentation says parameters are supported but the example uses hl and # which are unknown to me where I use c: and $ instead of this which is from the docs: <h:inputText value="#{userNumberBean.userNumber('5')}"> All I know about $ vs # in EL is that is has to do with rvalue and lvalue which I can need a further explanation when to use the # style. I'm looking for how an EL expression of typ $... can take a parameter and how to call non-getters non-setters with a parameter for example

${pageContext.request.contextPath} is not working on plain HTML

僤鯓⒐⒋嵵緔 提交于 2019-12-08 11:19:06
问题 I'm using tomcat 7.0. Now I am facing an issue that could not load the css and js file. trying to add ${pageContext.request.contextPath} but does not work, also tried c:url tag, but getting syntax error in eclipse. The structure of these files is: WebContent -content/css/lab3.css html and js folder are under content folder as well <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http:/

Getting a request parameter in a servlet from html form set with EL

谁说胖子不能爱 提交于 2019-12-08 11:13:19
问题 I have a JSP with the following EL/html tags: <c:forEach var="key" items="${resource.stringPropertyNames()}"> <tr> <td>${key}</td> <td><input type = "text" name = "${key}" value = "${resource.get(key)}"></td> </tr> </c:forEach> When my jsp is rendered, the first <td> tag shows the evaluated value of ${key}. In the <input> tag however, the ${key} is not evaluated correctly. When I try to retrieve the input as request parameters from my servlet ( request.getParameter(StringKey) ), I get the

Ways to include a dynamically generated facelet

荒凉一梦 提交于 2019-12-08 07:50:43
问题 In current project I need to create a panel that will contain an HTML content created by the user elsewhere in the application. This content can be easily inserted like this: <h:outputText value="#{myBean.dynamicHTMLContent}" escape="false"/> An example content: <p>User text</p> Now we need to give the user more freedom and allow him to use tokens in the HTML code that will be resolved by the application later: <p>User text</p><p>User image: {niceImage}</p> The application parses user content

How to pass an argument to method from rendered h:outputText?

匆匆过客 提交于 2019-12-08 07:27:27
I am displaying a table of data from an sql query and want to render a section of code based on one of the field values from this sql query. View: records.xthml <table> <thead> <tr> <td>#{messages['table.header.id']}</td> <td>#{messages['table.header.name']}</td> <td>#{messages['table.header.date.added']}</td> <td> </td> </tr> </thead> <tbody> <a4j:repeat value="recordListBean.records" var="listedRecord" rowKeyVar="index"> <tr> <td><h:outputText value="#{listedRecord.id}</td> <td><h:outputText value="#{listedRecord.name}</td> <td> <h:outputText value="#{listedRecord.dateAdded}" rendered="#