2

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 ?

2 Answers2

5

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

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

enter image description here

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

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Knut, thanks ... I have switched to keys="#{sessionScope.username}" and the service is returning the correct documents without error ... however, I also get the blank rows problem that Steve Zavocki blogged about. – Peter Della-Nebbia Mar 19 '15 at 21:03
  • 3
    Paul, I eventually fixed that issue, but honestly can't remember what I did. I have switched jobs since then, but will try to find a backup and see what I did to fix it. – Steve Zavocki Mar 19 '15 at 22:01
  • 1
    @Steve: that sounds great. Ones you found it just update your blog too and save this knowledge for all for ever :-D – Knut Herrmann Mar 19 '15 at 22:23
  • 1
    Added to my weekend task list. I will update what I did here, and in the blog post. – Steve Zavocki Mar 20 '15 at 11:08
  • @Paul and Knut, I am going to answer this as well, cause the comment doesn't allow me to format the code so that is readable (I tried) – Steve Zavocki Mar 21 '15 at 11:04
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.

Steve Zavocki
  • 1,840
  • 4
  • 21
  • 35