View Panel Flexibility

Home » View Panel Flexibility

I’ve seen a number of questions recently on StackOverflow related to extending the functionality of the View Panel.

Firstly, a bit of editorial. I am not a big fan of the View Panel. The XPages course I went on covered repeat controls on the second morning and every XPages developer should have covered repeat controls before they build their first production application. The View Panel seems to be very popular among newer developers, but the reason it’s popular is also the reason for the questions on StackOverflow. It allows you to easily map to columns and easily expose categorisation and column sorting from the underlying View design element. But it is specifically designed as a quick, easy, basic, way to display the contents of a view. Let me elaborate:

  • The source can only really be a Domino View.
  • The layout can only be a tabular format.
  • There is no easy flexibility with regard to categories. The View Panel does not let you change the twistie image, which is familiar to Notes Client users, but not to web users.
  • You have little control over anything outside each column.
  • It’s not designed for editability of content.

It’s possible to add components into a View Panel’s column. But to do so, you need to set the var property on the dominoView datasource, add a component into the column and bind it. At which point you’ve done virtually everything that you need to for a repeat control.

An XspViewEntry, which is effectively what the var property maps to, is read only. So to add editability, you need to get the underlying Document datasource via myVar.getDocument(). If more than one column is editable, you’re running the same code to calculate and retrieve the underlying Document multiple times, which is inefficient.

Basically, the View Panel is a crutch designed for very new developers. You can’t run while you’re using a crutch to walk, and your applications will be equally limited. So why not throw away your crutch and use a Repeat Control?

There’s only one argument that could be valid: consistency of look and feel. But that argument isn’t valid and hasn’t been for over a year. Because back in May 2013 I added onto XSnippets a snippet for allowing you to simulate the View Panel container’s look and feel and wrap a repeat control into it. I’ve just updated it as well if you don’t want to use a theme.

Personally, in most of my applications recently I’m using the Data View control instead. It gives all the flexibility of a Repeat Control while also allowing you to have some of the helpers that the View Panel has. It gives you a less “Notes-y” look and feel. After all, you’re building web applications now, so they should look and work more like a web application.

Both Repeat Controls and Data Views give the flexibility to do whatever you want without the restrictions of a View Panel. If you’re new to XPages and the View Panel does exactly what you need, by all means use it. But otherwise, it’s time to get familiar with the Repeat Control.

6 thoughts on “View Panel Flexibility”

    1. I’ve used other data sources but it get messy.

      Generally i use the View panel for very simple view, 2 or 3 columns Not categorised. Otherwise i use a repeat control.

      I do know of other developers that use them quite heavily unfortunately.

    2. I couldn’t see any other option on the drop-down, but I guess it can be computed. I hadn’t thought of that option. For anything that complex, a repeat control makes more sense.

  1. I have to agree that the View Control is meant for new developers. I wouldn’t go so far as to say “don’t use it in your first production application.” But I do tend to agree, anyone who learns how the Repeat Control works is going to be inclined to use that instead of the View Control.

    I actually haven’t worked with the Data View Control yet. I’ll be sure to give it a whirl!

    1. I’d agree that there may be simple applications where it does what is needed. My point was more that developers should ensure they understand repeat controls before creating their first production application. They’re not rocket science and if you need to do anything beyond a basic View Panel, the concepts used to extend the View Panel (setting var, referencing it in a control in a column etc) are the basis of Repeat Controls. The Data View is very powerful but has a lot of functionality, which is why it makes up about half of the XPages Extension Library chapter on views.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top