2017-07-20 108 views
0

我有在设计定义一个计算题自定义控件:使用计算值

text="<%=this.titleBarText%>"> 

我想传递一个标题,由JavaScript计算:

document1.isNewNote()?'New document':'Edit document' 

当我尝试它时,出现错误:

Error generating custom visualisation for this custom control. Markup validation failed. Ensure 'Design Definition' source is valid.

我的自定义控件在浏览器中正常工作,但我无法在所见即所得的编辑器中进行编辑。 我该如何处理这个错误?

设计定义:

<?xml version="1.0" encoding="UTF-8"?> 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"> 
    <xp:panel style='background-color:rgb(255, 255, 255);border-bottom-color:rgb(221, 221, 221);border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom-style:solid;border-bottom-width:1px;border-image-outset:0px;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;border-left-color:rgb(221, 221, 221);border-left-style:solid;border-left-width:1px;border-right-color:rgb(221, 221, 221);border-right-style:solid;border-right-width:1px;border-top-color:rgb(221, 221, 221);border-top-left-radius:4px;border-top-right-radius: 
4px;border-top-style:solid;border-top-width:1px;box-shadow:rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;box-sizing:border-box;color:rgb(51, 51, 51);display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif 
;font-size:14px;height:96px;line-height:20px;margin-bottom:20px;text-size-adjust:100%;width:592px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0);'> 
     <xp:panel style='background-color:rgb(245, 245, 245);background-image:linear-gradient(rgb(245, 245, 245) 0px, rgb(232, 232, 232) 100%);background-repeat-x:;background-repeat-y:;border-bottom-color: 
rgb(221, 221, 221);border-bottom-style:solid;border-bottom-width:1px;border-left-color:rgb(221, 221, 221);border-right-color:rgb(221, 221, 221);border-top-color:rgb(221, 221, 221);border-top-left-radius:3px;border-top-right-radius:3px;box-sizing:border-box;color:rgb(51, 51, 51);display:block;filter: 
none;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:14px;height:43px;line-height:20px;padding-bottom:10px;padding-left:15px;padding-right:15px;padding-top:10px;text-size-adjust:100%;width:590px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0);'> 
      <xp:link escape="true" style='background-color:rgba(0, 0, 0, 0);box-sizing:border-box;color:rgb(51, 51, 51);cursor:auto;display:inline;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:16px;height:auto;line-height:22.8571px;margin-bottom:0px;margin-top:0px;text-decoration:none;text-size-adjust:100%;width: 
auto;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)' 
       text="<%=(this.titleBarText?this.titleBarText:'Computed')%>"> 
      </xp:link> 
     </xp:panel> 

     <xp:panel style='box-sizing:border-box;color:rgb(51, 51, 51);display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:14px;height:51px;line-height:20px;text-size-adjust:100%;width:590px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)'> 

      <xp:panel style='border-top-color:rgb(221, 221, 221);box-sizing:border-box;color:rgb(51, 51, 51);display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:14px;height:30px;line-height:20px;padding-bottom:15px;padding-left:15px;padding-right:15px;padding-top:15px;text-size-adjust:100%;width:590px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)'> 
       <xp:callback facetName="panelBody" id="panelBody"></xp:callback> 
      </xp:panel> 

<% if(this.footer!='false'){ %> 
      <xp:panel style='background-color:rgb(245, 245, 245);border-bottom-left-radius:3px;border-bottom-right-radius:3px;border-top-color:rgb(221, 221, 221);border-top-style:solid;border-top-width:1px;box-sizing:border-box;color:rgb(51, 51, 51);display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:14px;height:21px;line-height:20px;padding-left:15px;padding-right:15px;text-size-adjust:100%;width:590px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)'> 
       <xp:callback facetName="panelFooter" id="panelFooter"></xp:callback> 
      </xp:panel><% }%> 
     </xp:panel> 
    </xp:panel> 
</xp:view> 
+1

这对我来说没有意义 - 设计定义是关于Designer中的设计元素。你可能想要做其他事情,请告诉我们你想做什么。 –

+0

是的,它是关于Designer中的设计元素。它停止工作,我想知道,为什么? – Antiokh

+0

更新您的问题并插入更改前的设计定义源。 –

回答

0

看来,唯一的方法是创建新的回调并计算主xpage内的标题。

  1. 添加新的属性定义:

enter image description here

  • 添加新的回调和修改的链路的呈现属性:

    <xp:callback facetName="customTitle" id="customTitle" 
        rendered="#{javascript:compositeData.custom_title}"> 
    </xp:callback> 
    <xp:link escape="true" styleClass="panel-title" 
        text="#{javascript:compositeData.titleBarText}" 
        rendered="#{javascript:!compositeData.custom_title}"> 
        <xp:this.attrs> 
         <xp:attr name="id"> 
          <xp:this.value><![CDATA[#{javascript:compositeData.panel_id + "_title"}]]></xp:this.value> 
         </xp:attr> 
        </xp:this.attrs> 
        <xp:this.id><![CDATA[${javascript:compositeData.panel_id + "_title"}]]></xp:this.id> 
    </xp:link> 
    
  • 更改设计定义:

  • enter image description here

    这就是全部。只需在主XPage中插入cumputed链接: enter image description here

    +0

    不错,虽然我不明白这是如何解决您的原始问题“在设计定义中使用来自数据源值**的计算值**”...... –

    +0

    是的,这不是原始问题的解决方案,只是解决方法。 – Antiokh

    +0

    我发现自定义属性有时会随机工作。一个自定义属性可以从重复var获取数据,另一个不能。 – Antiokh

    2

    document1.isNewNote()是一个测试,以检查是否在文档中浏览器中打开或XPiNC是新的。这是在运行时的测试。

    您正在寻找设计师在设计时间上展示您的自定义控件。这时没有文件可以显示状态。

    +0

    是的,你说得对,但我该如何避免这个问题呢? – Antiokh

    +0

    在设计定义中不能使用document1.isNewNote()。不可能。我假设你已经在自定义控件的计算字段中显示'新文档'/'编辑文档'。这还不够吗? –

    +0

    是的,似乎唯一的方法是创建新的回调并计算主xpage内的标题。 – Antiokh