【问题标题】:Primefaces. Error on client: JSON.parse: expected double-quoted property name at line 1 column 26 of the JSON data素面。客户端错误:JSON.parse:JSON 数据第 1 行第 26 列的预期双引号属性名称
【发布时间】:2016-03-14 07:13:42
【问题描述】:

我使用 PrimeFaces。我在客户端收到错误:SyntaxError: SyntaxError:JSON.parse:JSON 数据第 1 行第 26 列的预期双引号属性名称 http://localhost:8080/tfoms/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&v=5.3 第 25 行

我的代码:

org_dialog_page.xhtml 页面:

<h:form id="orgDetail">
<p:tabView id="orgTabView" widgetVar="orgDetailTabView" style="height: 500px" activeIndex="#{organizationBean.activeIndex}" >
    <p:tab title="General">
        <p:panelGrid id="orgDetails" columns="12" styleClass="full-width ui-org-details"
                                     columnClasses="label,value,validation_icon,label,value,validation_icon,label,value,validation_icon,label,value,validation_icon">
            <h:outputText value="INN:"/>
            <p:inputText id="innIndividual" widgetVar="innIndividual" style="width: 85px"
                         value="#{organizationBean.selectedOrganization.inn}"
                         rendered="#{organizationBean.selectedOrganization.regTypeName eq 'INDIVIDUAL'}"
                         validatorMessage="message">
                <f:validateRegex pattern="^([0]{1}|[0-9]{12})$"/>
                <p:clientValidator event="keyup"/>
                <p:ajax event="blur" process="@this"/>
            </p:inputText>
            <p:message rendered="#{organizationBean.selectedOrganization.regTypeName eq 'INDIVIDUAL'}"
                       for="innIndividual" display="icon"/>
            <p:inputText id="innLegal" widgetVar="innLegal" style="width: 85px"
                         value="#{organizationBean.selectedOrganization.inn}"
                         rendered="#{organizationBean.selectedOrganization.regTypeName ne 'INDIVIDUAL'}"
                         disabled="#{organizationBean.selectedOrganization.regTypeName eq 'NONE'}"
                         validatorMessage="message">
                <f:validateRegex pattern="^[0-9]{10}$"/>
                <p:clientValidator event="keyup"/>
                <p:ajax event="blur" process="@this"/>
            </p:inputText>

            ..........

        </p:panelGrid>
    </p:tab>    

</p:tabView>
<br/>
<p:commandButton rendered="#{securityBean.canUpdate(organizationBean.dictionaryClass)}"
                 value="Save" actionListener="#{organizationBean.save}" action="#{organizationCacheBean.reload}"
                 process="@form"  update="@widgetVar(orgTreeTable)"
                 oncomplete="autoScroll('.ui-organization-dict')"/>

org.xhtml 页面:

<p:treeTable value="#{organizationBean.rootNode}" var="organization" style="margin-top:0"
         styleClass="ui-scroll-treetable-70vh ui-organization-dict" selectionMode="single"
         selection="#{organizationBean.selectedNode}" widgetVar="orgTreeTable" id="orgTreeTable"
         emptyMessage="message" scrollable="true" scrollHeight="500" sortBy="#{organization.shortName}">
<p:ajax event="select" listener="#{organizationBean.onOrganizationSelect}" process="@this"
        update="@(.ui-organizations-toolbar)"/>
<p:column headerText="Name" style="width: 55%">
    <f:facet name="header">
        <h:outputText value="name"/> <br/>
        <p:inputText value="#{organizationBean.shortNameFilter}" size="30"
                     onkeypress="if (event.keyCode == 13) { filterOrgTree(); return false; }"/>
    </f:facet>
    <h:outputText value="#{organization.shortName}"/>
</p:column>

....

删除更新表后出现错误:update="@widgetVar(orgTreeTable)"

知道为什么会这样吗?

【问题讨论】:

  • 在 ajax 回答中我播种了错误的 JSON:{"validationFailed":true,} 知道为什么会这样???

标签: json jsf primefaces


【解决方案1】:

原因是在 treeTable 中排序

JSON 在此处返回答案中的以下行:

{ "验证失败": true,} 在 PrimePartialResponseWriter PrimeFaces 类库中,endDocument 方法就是形成这一行并添加参数 'validationFailed',而 encodeCallbackParams 方法就是形成这一行。但在此之前,在教室里和他的TreeTableRenderer 排序方法选择键中添加了null 值。因此,只需添加一个空白选项即可。

看文档p:treeTable,sortBy在treeTable中没有属性,而只在column中。因此,会发生错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-31
    • 2018-10-30
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    • 2018-08-02
    相关资源
    最近更新 更多