When a calendar day is selected you need to get the start of that calendar day end the end of that calendar day. Take a look at the documentation on how to create those objects. Now you can create a xpath where the Reservation/Start is greater then the beginning of that day but smaller then the end of that day. Then you have all the Reservation objects of that day. This list you can then filter by Student to filter out all the Reservations of a particular student.
You can also filter that first list for a specific tool by filtering it by Tool.
One note though. It is not necesarry to have the Student and Tool duplicated in the Reservation entity. You could use in the xpath the reference. But if you do duplicate, make sure these are synced right with the reference object.
If you need more pointers just ask.
Regards,
Ronald
Ronald:
Thanks for taking the time to respond. I've seen enough on the forum to know that you are a frequent contributor and want to start by thanking you and all of the other frequent contributors for helping make this forum such a valuable resource.
I also realize that I have the Student and Tool information duplicated in the Reservation. I fear that is a holdover from working with databases and systems that have independent tables that don't use associations ... and I clearly need to develop more expertise using associations to work effectively in the Mendix framework.
My closest attempt to use an association in the Calendar xpath query to limit the reservations to only those for a single tool looks like:
[MyFirstModule.Reservation_Tool/MyFirstModule.Tool = '[%CurrentObject%]']
Note: The entities that I'm trying to display are MyFirstModule.Reservation objects.
When I run my test application that results in the following stack track that, I think, shows that the CurrentObject is getting selected and loaded properly, but that I've got something wrong with my xpath statement.
I'm hopeful that you or someone will either see what is wrong in my above xpath query or will see what is wrong based on the runtime exception that is thrown:
> com.mendix.core.CoreRuntimeException:
> Exception occurred in action
> '{"amount":-1,"sort":[],"returnsCount":false,"offset":-1,"type":"RetrieveXPathSchemaRawAction","xpath":"//MyFirstModule.Reservation[MyFirstModule.Reservation_Tool/MyFirstModule.Tool
> = '8162774324609325']"}', all database changes executed by this action were
> rolled back
> at com.mendix.core.actionmanagement.CoreAction.processErrorState(SourceFile:343)
>
> Caused by:
> com.mendix.connectionbus.ConnectionBusRuntimeException:
> An exception has occurred for the
> following request(s):
> dc (depth = 0): //MyFirstModule.Reservation[MyFirstModule.Reservation_Tool/MyFirstModule.Tool
> = '8162774324609325']
> at com.mendix.l.a(SourceFile:59)
>
> Caused by:
> com.mendix.connectionbus.ConnectionBusRuntimeException:
> 'MyFirstModule.Reservation_Tool' is
> not a valid entity. The meta object is
> based on the last part of the
> following path:
> 'x1MyFirstModule.Reservation /
> MyFirstModule.Reservation_Tool',
> exception occurred on mapping the
> following query: SELECT
> x1MyFirstModule.Reservation.ID FROM
> MyFirstModule.Reservation AS
> x1MyFirstModule.Reservation INNER JOIN
> x1MyFirstModule.Reservation/MyFirstModule.Reservation_Tool
> AS j1myfirstmodule$reservation_tool
> WHERE
> x1MyFirstModule.Reservation/MyFirstModule.Reservation_Tool/MyFirstModule.Tool
> = '8162774324609325', exception occurred on mapping the following
> query: SELECT
> MyFirstModule.Reservation/* FROM
> MyFirstModule.Reservation WHERE
> MyFirstModule.Reservation.ID IN
> (SELECT x1MyFirstModule.Reservation.ID
> FROM MyFirstModule.Reservation AS
> x1MyFirstModule.Reservation INNER JOIN
> x1MyFirstModule.Reservation/MyFirstModule.Reservation_Tool
> AS j1myfirstmodule$reservation_tool
> WHERE
> x1MyFirstModule.Reservation/MyFirstModule.Reservation_Tool/MyFirstModule.Tool
> = '8162774324609325')
> at com.mendix.cS.v(SourceFile:264)
>
> Caused by:
> com.mendix.connectionbus.ConnectionBusRuntimeException:
> 'MyFirstModule.Reservation_Tool' is
> not a valid entity. The meta object is
> based on the last part of the
> following path:
> 'x1MyFirstModule.Reservation /
> MyFirstModule.Reservation_Tool',
> exception occurred on mapping the
> following query: SELECT
> x1MyFirstModule.Reservation.ID FROM
> MyFirstModule.Reservation AS
> x1MyFirstModule.Reservation INNER JOIN
> x1MyFirstModule.Reservation/MyFirstModule.Reservation_Tool
> AS j1myfirstmodule$reservation_tool
> WHERE
> x1MyFirstModule.Reservation/MyFirstModule.Reservation_Tool/MyFirstModule.Tool
> = '8162774324609325'
> at com.mendix.cS.v(SourceFile:264)
>
> Caused by:
> com.mendix.connectionbus.ConnectionBusRuntimeException:
> 'MyFirstModule.Reservation_Tool' is
> not a valid entity. The meta object is
> based on the last part of the
> following path:
> 'x1MyFirstModule.Reservation /
> MyFirstModule.Reservation_Tool'
> at com.mendix.cI.e(SourceFile:182)
Thank you for your consideration and support,
John
Ronald, Mike, and the Mendix Community:
I wish to report that suggestions from Ronald and Mike were exactly on target and have largely resolved the problems that I had been experiencing. For starters, I was not using relationships properly and, as a result, did not actually have any ReservationTool associations set up. As Ronald suggested (and likely also suspected) I was not managing the duplicate string Item and Student fields in my Reservation entity properly. I have since removed those and am relying solely on what I believe to be more appropriate use of the ReservationTool reference to specify the tool-matching condition for selecting reservations for a single tool. Mike was correct: the xpath filter that works is:
[MyFirstModule.Reservation_Tool = '[%CurrentObject%]']
Now the displayed reservations switch nicely when I select different tools and show only the reservations for that tool in the Calendar. Hooray!
I do have a minor remaining problem: When the application starts up, even though I have "Select first" in my data grids selected, it appears is if the initial rendering of the Calendar takes place before it has an initial CurrentObject because I can an initial error of:
com.mendix.core.CoreRuntimeException: Exception occurred in action '{"amount":-1,"sort":[],"returnsCount":false,"offset":-1,"type":"RetrieveXPathSchemaRawAction","xpath":"//MyFirstModule.Reservation [MyFirstModule.Reservation_Tool = '[%CurrentObject%]']"}', all database changes executed by this action were rolled back
That said, I'm light years ahead of where I was this morning thanks to help and suggestions from Ronald and Mike. Thank you for your help and for helping me to make a start learning how to properly use associations. I can see that developing better understanding and skill in this area will be a key to becoming a more effective Mendix user.
Thanks,
John