filenetibm-content-navigator

Setting minValue of date field dynamically in Content Navigator Entry Template


I am having a requirement in ICN Entry Template to prevent user from selecting a back date. I understand that this can be achieved using EDS and I have partly done it. I am able to set the MinValue to a static/hard coded date. But I am not very sure how to set the MinValue dynamically.

This is how I have done it.

{ "symbolicName": "date1", "label": "Date 1 : ", "minValue": "1982-09-10T01:18:17Z" }

This is how I want it to be:

{ "symbolicName": "date1", "label": "Date 1", "minValue": {now} OR {today} }

Any pointers would be greatly appreciated.


Solution

  • You are right, this is a problem I usually solve with EDS. What you need is Java servlet which dynamically generates the JSON. To avoid handling all the JSON stuff yourself you can use this library https://github.com/ecmdeveloper/eds-servlet to do most of the work for you.

    DISCLAIMER: I am the author of this library.

    Using this library your specific problem can be solved as follows:

    <dependencies>
        <dependency>
            <groupId>com.github.ecmdeveloper</groupId>
            <artifactId>eds-servlet</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    
    <properties><failOnMissingWebXml>false</failOnMissingWebXml></properties>
    
    @WebServlet(description = "An example of an EDS servlet.", urlPatterns = { "/type/*", "/types" })
    public class DateSampleEDS extends AbstractEDSServlet {
    
        private static final long serialVersionUID = 0xC00L;
    
        @Override
        public String[] getObjectTypeNames(String repositoryId) {
            return new String[] {"TestDocumentClass1"};
        }
    
        @Override
        public void handleRequest(ExternalDataRequest dataRequest, ExternalDataResponse dataResponse) {
    
            Property property = dataRequest.getProperty("TestDateProperty1");
            if ( property != null) {
                property.setMinValue(getToday());
                dataResponse.addProperty(property);
            }
        }
    
        private Calendar getToday() {
    
            Calendar calendar = Calendar.getInstance( TimeZone.getDefault() );
    
            calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY));
            calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE));
            calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND));
            calendar.set(Calendar.MILLISECOND, calendar.getActualMinimum(Calendar.MILLISECOND));
    
            return calendar;
        }
    }
    

    Entry Template Screenshot