任何人都对我如何解决这个警告有任何创造性的想法?
EL 语法错误:表达式不能以二元运算符开头
由以下代码引起:
String.format("#{myController.deleteItemById(%d)}", getId())
我的代码以前看起来像这样:
"#{myController.deleteItemById(" + getId() + ")}"
但这导致eclipse产生以下警告:
EL 语法错误:字符串未关闭
更新:
@ManagedBean(name = "myController")
@ViewScoped
public class MyController implements Serializable {
private long id;
private HtmlPanelGroup panel;
public long getId() {return this.id; }
private void getPanel() {
/// bunch of code for programatically creating a form
HtmlCommandButton deleteButton = new HtmlCommandButton();
deleteButton.setId(id);
deleteButton.setValue(value);
deleteButton.setActionExpression(/* EL expression used here */);
}
}
<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<!-- some other elements removed for the sake of clarity -->
<h:body>
<h:panelGroup binding="#{myController.panel}" />
</h:body>
</html>