问题描述
我有一个Primefaces数据表,可以在数据库中进行搜索。结果显示在数据表中,您可以在该行的末尾单击按钮,这会将您发送到另一页上,您可以在其中进行编辑。 我的最后一部分有问题。我尝试使用Inplace,但是当我单击末尾或行上的“编辑”按钮时,我无法在下一页获得当前元素。我尝试在下一页上发送当前元素的ID,但是没有工作。我尝试使用f:param,它可以...直到按SAVE按钮。我得到以下问题:
09:20:02,254 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-80) javax.faces.component.UpdateModelException: javax.el.PropertyNotWritableException: /SmpestsEditable.xhtml @37,74 value="#{request.getParameter('code')}": Illegal Syntax for Set Operation
SmpestsList.xhtml:
<p:dataTable id="pestsTbl" var="zuzek" value="#{smpestsList.pests}" editable="true"
style="margin-bottom:40px">
<f:facet name="header">
pestS
</f:facet>
<p:column headerText="Id">
<h:outputText value="#{zuzek.idpest}" />
</p:column>
<p:column headerText="Code">
<h:outputText value="#{zuzek.code}" />
</p:column>
<p:column headerText="Latin Name">
<h:outputText value="#{zuzek.latinName}" />
</p:column>
<p:column headerText="Image Recognition">
<h:outputText value="R-CNN"
rendered="#{zuzek.imgRecognition eq 1900}" />
<h:outputText value="NONE - copY MARKINGS"
rendered="#{zuzek.imgRecognition eq 1951}" />
<h:outputText value="SEGMENTATION"
rendered="#{zuzek.imgRecognition eq 1899}" />
</p:column>
<p:column headerText="Hide score">
<h:outputText value="#{zuzek.hidescore}" />
</p:column>
<p:column>
<p:linkButton outcome="SmpestsEditable" update="pestsListEdit" value="Edit" style="font-size:3em" title="edit">
<f:param name="id" value="#{zuzek.idpest}" />
<f:param name="code" value="#{zuzek.code}" />
<f:param name="lname" value="#{zuzek.latinName}" />
<f:param name="irecog" value="#{zuzek.imgRecognition}" />
</p:linkButton>
</p:column>
</p:dataTable>
SmpestsEditable.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<f:Metadata>
<f:viewParam name="id" value="#{smpestsEditable.id}" />
<f:viewParam name="code" value="#{smpestsEditable.code}" />
<f:viewParam name="lname" value="#{smpestsEditable.latinName}" />
<f:viewParam name="irecog" value="#{smpestsEditable.imgRecognition}" />
</f:Metadata>
<h:messages />
<h:head></h:head>
<h:body>
<style type="text/css">
.ui-row-editor .ui-row-editor-pencil {
margin-left:8px;
}
</style>
<h:form id="pestsListEdit">
<p:growl id="msgs" showDetail="true" />
<p:panel id="Searchpest" header="EDIT pest" toggleable="true"
closable="true" toggleSpeed="500" closeSpeed="500" widgetvar="panel"
style="margin-bottom:20px">
<p:panelGrid columns="2">
<h:outputLabel for="Id" value="Id" />
<h:outputText value="#{request.getParameter('id')}"/>
<h:outputLabel for="Id" value="Id" />
<p> View parameter is "#{smpestsEditable.id}"
</p>
<h:outputLabel for="Code" value="Code" />
<p:inplace id="Code" editor="true">
<p:inputText value="#{request.getParameter('code')}" label="Code" />
</p:inplace>
<h:outputLabel for="" value="Latin Name" />
<p:inplace id="Latin">
<p:inputText value="#{request.getParameter('lname')}" label="Latin name" />
</p:inplace>
<h:outputLabel for="Recog" value="Image Recognition" />
<p:inplace id="Recog" label="Image Recognition" event="dblclick" value=#{request.getParameter('irecog')}" >
<h:selectOneMenu id="selectOne">
<f:selectItem itemLabel="SEGMENTATION" itemValue="1899" />
<f:selectItem itemLabel="R-CNN" itemValue="1900" />
<f:selectItem itemLabel="NONE - copY MARKINGS" itemValue="1951" />
</h:selectOneMenu>
</p:inplace>
<f:facet name="footer">
<p:commandButton value="SAVE"
actionListener = "#{smpestsEditable.saveButton}"
action = "SmpestsList?faces-redirect-true" />
<p:linkButton outcome="SmpestsList" value="CLOSE"
style="margin-right:20px;">
</p:linkButton>
</f:facet>
</p:panelGrid>
</p:panel>
<p:dataTable var="ime" value="#{smpestsEditable.imena}">
<p:column headerText="ID pest NAME">
<h:outputText value="#{ime.idpestName}" />
</p:column>
<p:column headerText="LANGUAGE">
<h:outputText value="Srpski"
rendered="#{ime.idLanguage eq 12}" />
<h:outputText value="Français"
rendered="#{ime.idLanguage eq 13}" />
<h:outputText value="Italiano"
rendered="#{ime.idLanguage eq 8}" />
<h:outputText value="Slovensko"
rendered="#{ime.idLanguage eq 1}" />
<h:outputText value="English"
rendered="#{ime.idLanguage eq 4}" />
<h:outputText value="Português"
rendered="#{ime.idLanguage eq 9}" />
<h:outputText value="Deutsch"
rendered="#{ime.idLanguage eq 11}" />
<h:outputText value="Magyar"
rendered="#{ime.idLanguage eq 10}" />
<h:outputText value="Português"
rendered="#{ime.idLanguage eq 14}" />
<h:outputText value="Yкраїнський"
rendered="#{ime.idLanguage eq 15}" />
</p:column>
<p:column headerText="disPLAY NAME">
<p:inplace id="name">
<p:inputText value="#{ime.name}" label="Name" />
</p:inplace>
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
SmpestsEditable.java:
@Named(value="smpestsEditable")
@RequestScoped
public class SmpestsEditable {
private List<SmpestsNames> pests = new ArrayList<SmpestsNames>();
private EntityManager em =null;
private EntityManagerFactory emf = Persistence.createEntityManagerFactory("tvTutorialPU");
private int stevilka;
private int id;
private int idpest=77;
Smpests zuzek1=loadpestById(idpest);
private String code = zuzek1.getCode();
private String oldCode = code;
private String latinName = zuzek1.getLatinName();
private String oldLatinName = latinName;
private String refLink = zuzek1.getRefLink();
private String oldRefLink = refLink;
private Integer imgRecognition = zuzek1.getImgRecognition();
private Integer oldImgRecognition = imgRecognition;
private Integer hidescore = zuzek1.getHidescore();
private Integer oldHidescore = hidescore;
private Integer recognitionModel = zuzek1.getRecognitionModel();
private Integer oldRecognitionModel = recognitionModel;
private Double alarmThresholdUp = zuzek1.getAlarmThresholdUp();
private Double oldAlarmThresholdUp = alarmThresholdUp;
private Double alarmThresholdLow = zuzek1.getAlarmThresholdLow();
private Double oldAlarmThresholdLow = alarmThresholdLow;
List<SmpestsNames> imena = zuzek1.getSmpestsNames();
private Long idpestName;
private int idLanguage;
private String name;
private LocalDateTime dInsert;
private Long idInserter;
private LocalDateTime dUpdate;
private Long idUpdater;
Smpests zuzek;
public void saveButton() {
System.out.println("SAVE button");
}
private Smpests loadpestById(int id) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("tvTutorialPU");
EntityManager em = emf.createEntityManager();
Smpests zuzek = em.find(Smpests.class,id);
return zuzek;
}
如果我忘了提任何事情,请告诉。我正在使用Postgres,Wildfly 17。 PS:现在我在发布代码,我剥离了函数saveButton,使它现在只应该打印“ SAVE button”,但它仍然给我同样的错误:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)