有人可以帮我解决我在JSF上的新问题。我用Primefaces构建了一个Spring WebMVC应用程序。这个应用程序包含一个节点列表,可以将其拖入spreadSheet(我正在使用SpreadJS)。每个节点后面都有一个模型和一个bean。 Evey节点具有名称和输入类型。我需要在spreadSheet中进行节点值与其值之间的同步,反之亦然。因此,在每个changeEvent中,我调用一个remoteCommand,并将五个参数传递给我的managedBean。问题是每当我加载我的页面时我都会收到此错误:这是我的代码:
@ManagedBean
@SessionScoped
public class HelloBean implements Serializable {
private static final long serialVersionUID = 1L;
@ManagedProperty("#{param.nodeId}")
private String nodeId;
@ManagedProperty("#{param.paramId}")
private String paramId;
@ManagedProperty("#{param.row}")
private int row;
@ManagedProperty("#{param.cel}")
private int cel;
@ManagedProperty("#{param.value}")
private String value;
public String getNodeId() {
return nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public String getParamId() {
return paramId;
}
public void setParamId(String paramId) {
this.paramId = paramId;
}
public int getRow() {
return row;
}
public void setRow(int row) {
this.row = row;
}
public int getCel() {
return cel;
}
public void setCel(int cel) {
this.cel = cel;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public void execCmd() {
Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String nodeId = params.get("nodeId");
}
和我的xhtml文件看起来像:
<h:body>
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<h:form id="myForm">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4">Test Submit Value</label>
<h:inputText name="text1" id="text1" value="#{helloBean.value}" >
</h:inputText>
</div>
</div>
<p:remoteCommand name="callRemoteMethod" actionListener="#{helloBean.execCmd()}" />
</h:form>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div name="right_frame" id="ss" style="height: 600px; width: 100%;"></div>
</div>
</div>
</div>
<h:form>
<br />
</h:form>
</h:body>
<script type="text/javascript">
var nodeId = null;
var paramId = null;
var row = null;
var cell= null;
var value = null;
var spread;
window.onload = function() {
spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var sheet = spread.getActiveSheet();
sheet.setValue(0, 1, 123, GC.Spread.Sheets.SheetArea.viewport);
sheet.bind(GC.Spread.Sheets.Events.CellChanged , function (e, args) {
if (args.propertyName === "value") {
if(sheet.getTag(0,1) != null){
var obj = JSON.parse(sheet.getTag(0,1));
nodeId = obj.nodeId;
paramId = obj.paramId;
row = args.row;
cell = args.col;
callRemoteMethod({name: 'nodeId', value: ""}, {name: 'paramId', value: ""}, {name: 'row', value: 1}, {name: 'cel', value: 1}, {name: 'value', value: "Test"}]);
}
}
});
};
</script>
</html>
这就是Stack Trace:
Caused by: java.lang.IllegalArgumentException: can't parse argument number: param.nodeId
at java.text.MessageFormat.makeFormat(MessageFormat.java:1420)
at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
at java.text.MessageFormat.<init>(MessageFormat.java:363)
at java.text.MessageFormat.format(MessageFormat.java:835)
at com.sun.faces.util.MessageUtils.getExceptionMessageString(MessageUtils.java:396)
at com.sun.faces.mgbean.BeanBuilder$Expression.validateLifespan(BeanBuilder.java:604)
at com.sun.faces.mgbean.BeanBuilder$Expression.<init>(BeanBuilder.java:553)
at com.sun.faces.mgbean.ManagedBeanBuilder.bakeBeanProperty(ManagedBeanBuilder.java:363)
at com.sun.faces.mgbean.ManagedBeanBuilder.bake(ManagedBeanBuilder.java:107)
... 49 more
Caused by: java.lang.NumberFormatException: For input string: "param.nodeId"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
at java.text.MessageFormat.makeFormat(MessageFormat.java:1418)
... 57 more
任何帮助??
答案 0 :(得分:0)
您正在将Integer
的值设置为String
变量,例外情况
java.lang.NumberFormatException:对于输入字符串:“param.nodeId”
nodeId
变量应为Integer
变量。
或强>
您可以使用Integer
方法
toString()
值
答案 1 :(得分:-1)
而不是@ManagedProperty(“#{param.nodeId}”),我创建了@ManagedProperty(“#{nodeId}”)并且它可以工作:
@ManagedProperty("#{nodeId}")
private String nodeId;
@ManagedProperty("#{paramId}")
private String paramId;
@ManagedProperty("#{row}")
private int row;
@ManagedProperty("#{cel}")
private int cel;
@ManagedProperty("#{value}")
private String value;