Monday, April 30, 2012

Wicket 1.5 and general models

NextReports Server is in process for Wicket 1.5 migration. A lot of things need to be addressed, but in particularly one of them has to be noticed.

Running reports in NextReports Server consists of a number of steps, one of them being selecting parameters. Depending of parameter's type, user can choose the values using a specific UI component like text field, check box, combo box, calendar, selection lists and so on.

Model used for a parameter is something generic like Serializable, because it's type can be anything. One problem appeared at migration from version 1.4 to version 1.5. A simple String TextField with a Serializable model (objectModel in our case):
TextField<String> textField = new TextField<String>("txtValue",
                new PropertyModel<String>(this, "objectModel"));
When we put a value in our text field, on submit we get : "is not a valid Serializable" error. That shows us Wicket 1.5 does not know that String declaration in our case is a Serializable type. To make models accept a general type , we should now create also the converter used by the component to specify the class type:
TextField<String> textField = new TextField<String>("txtValue",
                new PropertyModel<String>(this, "objectModel")) {
            
      @Override
      public <C> IConverter<C> getConverter(Class<C> type) {
          return new AbstractConverter() {

              public Object convertToObject(String value, Locale locale) {
                  return value;
              }

              @Override
              protected Class getTargetType() {
                  return String.class;
              }
                    
          };
      }

Wednesday, April 18, 2012

NextReports : Row Formatting Conditions

Till version 5.2 NextReports allowed only cell formatting conditions. But the new version will also bring the possibility to add row formatting conditions.

User can select now a row


and row properties will be seen:


 Clicking on formatting conditions, user can add, edit or remove them:


In this example we just alternate background color for rows:

We can go further and alternate not rows, but records data. Consider the following report:


We will modify row formatting conditions for all rows like following:


We will obtain:

We can modify more properties for a row formatting condition. For next report:

 we will select background and border properties:

 Result is:

We can have any expression used for row formatting. Next shows a row formatting simulation if productivity is less than 50%:




If you want to combine cell and row formatting conditions, keep in mind that cell formatting conditions will overwrite row formatting conditions.