How to configure an xe:viewFileItemService on an XPage to filter the data in a categorized view?

倖福魔咒の 提交于 2019-12-08 01:20:54

问题


I have a DocsByUsername categorized view, sorted and categorized by the username. For the authenticated user I only want to display their documents in a Dojo Data Grid. The grid needs to support in-grid editing so I need to use an xe:viewFileItemService read/write service as the data source for the grid.

I thought this would be fairly straight forward using the following service configuration ...

    <xe:restService id="restService1" jsId="restServiceObj"
        pathInfo="pathinfo">
        <xe:this.service>
            <xe:viewItemFileService
                viewName="DocsByUsername" var="rsEntry"
                contentType="application/json" defaultColumns="true"
                sortColumn="Username" categoryFilter="#{sessionScope.username}">
            </xe:viewItemFileService>
        </xe:this.service>
    </xe:restService>

When I preview the page and append the /pathinfo to the url to test the service the following error is returned ...

{
   "code":500,
   "text":"Internal Error",
   "message":"",
   "type":"text",
   "data":"java.lang.NullPointerException\r\n\tat 
      ... removed for space ...

}

If I switch from xe:viewFileItemService to xe:viewJsonService the data is properly returned without error.

Can I not specify a Categorized view for xe:viewFileItemService ?


回答1:


Use parameter keys instead of categoryFilter. That gives you back all documents for username's category.

... keys="#{sessionScope.username}">

Steve Zavocki had a blog about this issue a while ago.




回答2:


Paul, I just found that database and here is what I did. Despite trying everything, I could not find a way to get rid of the blank row using keys.

What I did was go back to the categoryFilter and put this code into it:

var category:String = lineItemBean.getThisUNID();
if(category == null){
    return "show nothing"
} else {
    return lineItemBean.getThisUNID();
}

The lineItemBean is a managed bean bound to session. The getThisUNID() is a simple getter for the parents UNID stored as a String. The child records are tied to the parent by this UNID. The view is categorized by this. If it can't find the parent UNID it searches for the category "show nothing" which of course it never finds, else return the documents. Before I did this, it would show ALL documents for in this case (very bad).

My rest service is of type xe:viewJsonService. FYI, this grid is also set to allow in row editing. Also, it shouldn't make a difference, but the data is stored in a separate database from the design. Hope this helps.



来源:https://stackoverflow.com/questions/29153238/how-to-configure-an-xeviewfileitemservice-on-an-xpage-to-filter-the-data-in-a-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!