I'm making a project to school in JSF and I have few problems with that.
First of all, the h:commandButton doesn't work properly when I want to redirect myself to another page of the project by pushing it. There is an error displayed:
javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
index.jsp:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<head>
<title>Firma Komputerowa - Baza Danych</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/table-style.css" />
</head>
<body>
<f:view>
<h:form>
<h:panelGrid columns="3">
<h:commandButton action="#{producentBean.redirect }" value="Dodaj"/>
</h:panelGrid>
<h:panelGrid>
<h:dataTable value="#{producentBean.List}" var="p"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row" border="1" >
<h:column>
<f:facet name="header">ID producenta</f:facet>
<h:inputText value="#{p.getId}"/>
</h:column>
<h:column>
<f:facet name="header">Nazwa producenta</f:facet>
<h:inputText value="#{p.getNazwa}" />
</h:column>
<h:column>
<f:facet name="header">NIP</f:facet>
<h:inputText value="#{p.getNip}" />
</h:column>
<h:column>
<f:facet name="header">REGON</f:facet>
<h:inputText value="#{p.getRegon}" />
</h:column>
<h:column>
<f:facet name="header">Miasto</f:facet>
<h:inputText value="#{p.getMiasto}" />
</h:column>
<h:column>
<f:facet name="header">Adres</f:facet>
<h:inputText value="#{p.getAdres}" />
</h:column>
<h:column>
<f:facet name="header">Telefon</f:facet>
<h:inputText value="#{p.getTel}" />
</h:column>
<h:column>
<f:facet name="header">E-mail</f:facet>
<h:inputText value="#{p.getEmail}" />
</h:column>
</h:dataTable>
</h:panelGrid>
</h:form>
</f:view>
...
</body>
</html>
ProducentBean.java:
public class ProducentBean extends Polacz implements Serializable {
public String redirect() {
return "dodaj_pr";
}
}
I was trying to do it in many ways, but I can't deal with it.
I also have an another question: is there in JSF a possibility to display a table dynamically from database, for example by choosing a table name selecting an option in ? My database contains three tables with different count of colums each.
I'll be very happy if somebody gives me some advices.
EDIT:
OK, I tried to do this:
private String dodajPrUrl = "dodaj_pr?faces-redirect=true";
public String getDodajPrUrl() {
return this.dodajPrUrl;
}
public void setDodajPrUrl(String newUrl) {
this.dodajPrUrl = newUrl;
}
and in index.jsp:
<h:commandButton action="#{producentBean.redirect }" value="Dodaj" />
It gives me still the same error.
EDIT2:
Stack trace:
SEVERE: javax.faces.FacesException: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
javax.faces.FacesException: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:142)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.faces.component.UpdateModelException: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
at javax.faces.component.UIInput.updateModel(UIInput.java:853)
at javax.faces.component.UIInput.processUpdates(UIInput.java:735)
at javax.faces.component.UIData.iterate(UIData.java:2001)
at javax.faces.component.UIData.processUpdates(UIData.java:1253)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1242)
at javax.faces.component.UIForm.processUpdates(UIForm.java:281)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1242)
at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1231)
at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
... 26 more
Caused by: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
at com.sun.el.parser.AstValue.setValue(AstValue.java:207)
at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:291)
at javax.faces.component.UIInput.updateModel(UIInput.java:818)
... 35 more
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…