B4J Question [ABMaterial] ABMDateTimeScroller doesn't accept my date setting.

mcGeorge

Member
Licensed User
Longtime User
Hi there,
I use a ABMDateTimeScroller control in a modalsheet:

B4X:
Sub BuildModalSheet() As ABMModalSheet
    Dim myModal As ABMModalSheet
    myModal.Initialize(page, "fixedsheet", False, ABM.MODALSHEET_TYPE_NORMAL, "")
    myModal.Content.UseTheme("modalcontent")
........
    Dim oSTART As ABMDateTimeScroller
    oSTART.Initialize( page, "oSTART", ABM.DATETIMESCROLLER_TYPE_TIME, ABM.DATETIMESCROLLER_MODE_CLICKPICK, DateTime.Now, "", "" )
    oSTART.CancelText = "Abbrechen"
    oSTART.PickText = "Speichern"
    oSTART.TitleTimeFormat  = "HH:ii"
    oSTART.ReturnTimeFormat = "HH:ii"
    oSTART.TimeShowAMPM = False
    myModal.Content.Cell(3,2).AddComponent( oSTART )
.......

When I click on a button on my "normal" page the modal sheet should open and show a specific time:

B4X:
......
    page.ShowModalSheet("TimeSheet")
    Dim mymodal As ABMModalSheet = page.ModalSheet("TimeSheet")
    Dim oSTART As ABMDateTimeScroller = mymodal.Content.Cell(3,2).Component("oSTART")
.....
    Dim lDT As Long = DateTime.TimeParse( tbl.GetString( tblCellInfo.Row, 4 ) & ":00" )
    Log( DateTime.Time( lDT ) ) 'The time is correct, I see it in the log
    oSTART.SetDate( lDT )
    oSTART.Refresh
......

but it doesn't work! I see still the initial time only and I didn't get any error message.

What is my mistake?

Thanks for any help
George
 

mcGeorge

Member
Licensed User
Longtime User
Yes
upload_2019-1-7_10-36-43.png
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Those errors shouldn't matter. They just mean the logo.png file is missing.

As for the date thing, have your tried refreshing the whole modal sheet instead of oSTART.Refresh?

B4X:
' oSTART.Refresh
mymodal.refresh

And see what happens if you run page.ShowModalSheet("TimeSheet") AFTER you've set the new date instead of before
B4X:
......
    Dim mymodal As ABMModalSheet = page.ModalSheet("TimeSheet")
    Dim oSTART As ABMDateTimeScroller = mymodal.Content.Cell(3,2).Component("oSTART")
.....
    Dim lDT As Long = DateTime.TimeParse( tbl.GetString( tblCellInfo.Row, 4 ) & ":00" )
    Log( DateTime.Time( lDT ) ) 'The time is correct, I see it in the log
    oSTART.SetDate( lDT )
    ' try it also without this line as page.ShowModalSheet should do a refresh anyway
    oSTART.Refresh
    page.ShowModalSheet("TimeSheet")
......
 
Upvote 0

mcGeorge

Member
Licensed User
Longtime User
I did it and it changed.

Now the first assign of a time value works, but if I open the modal sheet a second time, the first value is still there and the new time value doesn't appear.

That is not logical?
 

Attachments

  • upload_2019-1-7_10-55-47.png
    upload_2019-1-7_10-55-47.png
    15.2 KB · Views: 201
Upvote 0

mcGeorge

Member
Licensed User
Longtime User
I added the module here, maybe you have an idea!?

This is the "normal" page:
upload_2019-1-7_11-4-24.png


and this is the modal page:
upload_2019-1-7_11-5-12.png


and you see here the mistake, I clicked on the first project PR180265 with the time 20:00 and in the modal sheet is still 20:17 from the first opened project PR180305.
 

Attachments

  • frmJobListe.bas
    20.9 KB · Views: 214
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
hmm, I can of course not replicate your project 100% because of the queries, but if it simply put a button on a page with your modalsheet and with this code:

B4X:
' in Class_Globals I defined Dim tim As Int = 10

Sub btn1_Clicked(Target As String)   
 
   page.ShowModalSheet("TimeSheet")
   
   Dim mymodal As ABMModalSheet = page.ModalSheet("TimeSheet")
   Dim oSTART As ABMDateTimeScroller = mymodal.Content.Cell(3,2).Component("oSTART")
   Dim oLB11 As ABMLabel = mymodal.Content.Cell(1,1).Component("oLB11")
   Dim oLB12 As ABMLabel = mymodal.Content.Cell(1,2).Component("oLB12")
   Dim oLB13 As ABMLabel = mymodal.Content.Cell(1,3).Component("oLB13")
           
'   oLB11.Text = oButton.Text
'   oLB11.Refresh
'
'   oLB12.Text = tbl.GetString(tblCellInfo.Row,1)
'   oLB12.Refresh
'
'   oLB13.Text = tbl.GetString(tblCellInfo.Row,3)
'   oLB13.Refresh
   
   tim = tim + 1       
   Dim lDT As Long = DateTime.TimeParse(tim & ":00:00" )
   oSTART.SetDate( lDT )
   oSTART.Refresh
   
End Sub

every time I click the button, the new time is shown:

11:00:00
12:00:00
13:00:00
etc...
 
Upvote 0

mcGeorge

Member
Licensed User
Longtime User
Not sure what the reason for this issue is currently...

I did a reboot of the server and moved the application in a different folder and started the application. Suddenly I have the following error in my log.
Any ideas what's now wrong?

B4X:
loading M:\DEV\ADVR5WEB\Objects: copymewithjar.needs...
Using cache system: 3.0
Current App version: 1546903116114
Needs material/awesome icons
Building M:\DEV\ADVR5WEB\Objects\copymewithjar.js.needs
Building core.min.1546903116114.css...
java.nio.file.NoSuchFileException: M:\DEV\ADVR5WEB\Objects\www\css\mobiscroll.min.css
    at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
    at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
    at java.nio.file.Files.newByteChannel(Files.java:361)
    at java.nio.file.Files.newByteChannel(Files.java:407)
    at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
    at java.nio.file.Files.newInputStream(Files.java:152)
    at java.nio.file.Files.newBufferedReader(Files.java:2784)
    at java.nio.file.Files.readAllLines(Files.java:3202)
    at com.ab.abmaterial.ABMPage.WritePageToDiskPerTheme(Unknown Source)
    at com.ab.abmaterial.ABMPage.WritePageToDisk(Unknown Source)
    at com.ab.abmaterial.ABMaterial.WritePageToDisk(Unknown Source)
    at com.ab.abmaterial.ABMaterial.WriteAppLauchPageToDisk(Unknown Source)
    at technology.ghg.advr5.abmapplication._startserver(abmapplication.java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:627)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:233)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at technology.ghg.advr5.main.main(main.java:29)
2019-01-07 18:18:37.557:INFO::main: Logging initialized @2061ms to org.eclipse.jetty.util.log.StdErrLog
2019-01-07 18:18:37.682:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_191-b12
2019-01-07 18:18:37.731:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2019-01-07 18:18:37.731:INFO:oejs.session:main: No SessionScavenger set, using defaults
 
Upvote 0

mcGeorge

Member
Licensed User
Longtime User
I am closer to the reason for that issue:
My thought was, always when the time in [Startzeit] or [Endezeit] has changed the [Dauer] should be new calculated.

I wrote for that this function:
B4X:
Sub CalcDauer()
    Dim mymodal As ABMModalSheet = page.ModalSheet("TimeSheet")
    Dim oSTART As ABMDateTimeScroller = mymodal.Content.Cell(3,2).Component("oSTART")
    Dim oEND As ABMDateTimeScroller = mymodal.Content.Cell(3,4).Component("oEND")
    Dim oLBL4 As ABMLabel= mymodal.Content.Cell(3,6).Component("oLBL4")
    Dim lEnd As Long = DateTime.TimeParse( oEND.GetDateISO.SubString( oEND.GetDateISO.Length - 8 ) )
    Dim lStart As Long = DateTime.TimeParse( oSTART.GetDateISO.SubString( oSTART.GetDateISO.Length - 8 ) )
    Dim iMinutes As Int = (lEnd - lStart) / 60000
    Dim iAnz As Int = iMinutes Mod 60
    Dim iHours As Int = (iMinutes - iAnz) / 60
   
    oLBL4.Text = NumberFormat( iHours, 2, 0 ) & ":" & NumberFormat( iAnz, 2, 0 )
    oLBL4.Refresh
End Sub

But If I use this function I wasn't able to change the time in these controls.
Had someone an idea why?

Thanks in advance.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
This demo project illustrating the problem was of great help!

There are two issues here at work:

1. You cannot mix both Date and DateISO. I've should've explained that more, so I'm to blaim for that.
2. In the original javascript library, there seems to be a problem with SetDate. I will have to figure that out how to fix.

The good news is that we have a workaround: we will only use the ISO methods

1. Change the Initialize method to:
B4X:
oSTART.InitializeISO( page, "oSTART", ABM.DATETIMESCROLLER_TYPE_TIME, ABM.DATETIMESCROLLER_MODE_MIXED, "1970-01-01T00:00:00", "", "" )

2. Whenever your want to set the date, use SetDateISO:
B4X:
oSTART.SetDateISO("1970-01-01T" & tim & ":00:00" )

3. Whenever you need to get the date, use GetDateISO (but that is what you already did)
B4X:
Dim lStart As Long = DateTime.TimeParse( oSTART.GetDateISO.SubString( oSTART.GetDateISO.Length - 8 ) )
 
Upvote 0
Top