cancel
Showing results for 
Search instead for 
Did you mean: 

Date Validation in Aikau widget

anshu_kumar
Star Contributor
Star Contributor
Hello Guys,

I have a very basic requirement for which I am using Aikau widgets to develop.
The requirement is to have a form based selection of 'FROM' and 'To' dates. I am able to populate the Date textbox using "alfresco/forms/controls/DateTextBox" widget. However, I need to put a validation in which 'from' date should always be less than 'to'. Can someone help me achieve this. Thanks. Below is the piece of code that shows the dates selection.

<javascript>
var date = new Date();
var todayDate = date.toISOString();

model.jsonModel = {
   
    widgets: [
   {
      id: "FROM_DATE",
      name: "alfresco/forms/controls/DateTextBox",
      config:   {
         label: "FROM",
         name: "fromDate",
         value: todayDate
      }
    },
   {
      id: "TO_DATE",
      name: "alfresco/forms/controls/DateTextBox",
      config:   {
         label: "TO",
         name: "toDate",
         value: todayDate
      }
    }   
]};
</javascript>
28 REPLIES 28

ddraper
World-Class Innovator
World-Class Innovator

Yes, I understand that ... the point is you probably shouldn't be...

If you really want to take this approach (and I strongly don't recommend it) then you actually want to be using the Dijit registry as this will actually find you the widget on which you can call the getValue function.

However, as I say this is not a sensible approach to take. What I don't understand is why you don't have a reference to you the widgets and what you're hoping to do with the data when you get it. Like I said before, if you explain the use case (as in the steps that the user is going to go through to work with the UI that you're implementing) then I may be able to help guide you on a better implementation.

Thanks a lot.

tansadio
Confirmed Champ
Confirmed Champ

Here is my subject(summary):

First, i have some widget to filter AlfListView( TextBox, Select, DateTextBox, etc...).

Then, When The widget TextBox change, I get he value with  PublishTopic and i want acces to the value Select or DateTextBox in function that catch PublishTopi.

Thanks,

ddraper
World-Class Innovator
World-Class Innovator

OK, so in that case why not use the AlfFilteredList​ to contain your AlfListView... this extends the basic list capabilities to allow you to provide form control widgets to indicate how the widget should be filtered (using the widget) attribute. This video shows how you can used this widget for filtering (it is a demonstration of how to build up a page).

This would probably be a better approach to filtering a list. There are further examples of using this in the Aikau unit test application - the controller can be found here.

Hi Dave Draper​,

I'll come back at you. I used AlfFilteredList to contain my AlfListView and I define some widget like (TextBox, FilteringSelect, DateRange) in property widgetsForFilters (ALfFilteredList) and evrything work perfectly about filter but when i add widget Paginator after AlfFilteredList that's give some problem during the click on button forwad paginator the request reload my page twice.

First when my page load this code run:

{

    name: "alfresco/lists/AlfFilteredList",

    config:

    {

      loadDataPublishTopic: "ALF_CRUD_GET_ALL",

      loadDataPublishPayload: {

     url: "ceri/supplierfolder",

      },

      itemsProperty: "alldocument",

     .....

},

{

       name: "alfresco/lists/Paginator",

       config: {

          documentsPerPage: 5,

          pageSizes: [3, 5,10],

       }

}

I do not understand why my page is twice reloaded. The red is call when i click on button forward paginator and answer realod page and call the blue request.

forward.PNG

I need your help.

Thanks for advance

ddraper
World-Class Innovator
World-Class Innovator

One of the main issues I encountered when developing Aikau is the inconsistency in the schema of the REST APIs that Alfresco had originally developed (this is subsequently being addressed with the new versionable APIs that are being developed). One of the issues is how pagination data is handled - for example, sometimes the API is expecting "pageSize" and "page" parameters, sometimes it is expecting "skipCount" and "maxItems", sometimes it's expecting "startIndex", etc.

This is one of the reasons why Aikau has separate services for requesting data - because they can normalize the data into a consistent schema that the widgets expect.

It would definitely be worth checking that the API you're using supports the pagination parameters that you're passing... it might be that you're not able to use the CrudService and that you need to have a custom service.

Are you calling a custom API that you've written or is it an Alfresco API? Does it definitely handle pagination? What parameters is it expecting?

Why you're getting an error I can't be sure - I'd usually recommend breaking on exceptions in the debugger and/or stepping through the loadData functon and subsequent function calls to understand what is happening.

I dont' know why i encountered this problem. I have a custom api that i call via  loadDataPublishTopic: "ALF_CRUD_GET_ALL" and the response of my api return Json data contain ("totalRecords": 6,  "startIndex": 0, alldocument: [...]).

I don't know how i can resolve this today.

Need more help please.

Thanks

ddraper
World-Class Innovator
World-Class Innovator

I don't have enough information to help you further unfortunately as I don't have access to your environment or code... I've given you some suggestions for how you can try to debug the problem. Have you followed any of those? Have you tried breaking on exceptions or stepping through the code?

Thanks for your fast answer. Do you have somewere a simple example on how use AlfFilteredList and Paginator.

ddraper
World-Class Innovator
World-Class Innovator

I provided links earlier in this thread... there's a video and you can review the examples in the unit test application. The people page example I also provided uses it.