B4J Tutorial SithasoDaisy TailwindCSS UI Toolkit: Q & A

Mashiane

Expert
Licensed User
Longtime User
I have updated the project. These are the changes made.



  • Use hamburger to show & close the drawer.
  • Click a button and generate a text file & download it.
 

Attachments

  • WriteTextFileAndDownload.zip
    44.7 KB · Views: 83

Mashiane

Expert
Licensed User
Longtime User
You call a http, this needs to be called not from https, in your case it gives a 404.

This is the output with.

B4X:
Dim postal As SDUIAxios
    postal.Initialize("http://cep.republicavirtual.com.br/web_cep.php")
    'add a parameters
    postal.AddParameter("cep", "30130003")
    postal.AddParameter("formato", "json")
    'execute the post
    banano.Await(postal.GetWait)
    Log(postal.Status)
    Log(postal.Data)



SDUIFetch is based on BANanoFetch, Im not sure why it gives a blank.
 

Attachments

  • 1677052586016.png
    24 KB · Views: 70
  • postalCode.gif
    114.5 KB · Views: 66
  • axios api call.zip
    45.3 KB · Views: 77
Last edited:

alwaysbusy

Expert
Licensed User
Longtime User
Native BANano works just fine, so something must be wrong in your SDUIFetch wrapper.

B4X:
Dim fetch As BANanoFetch
Dim fetchOptions As BANanoFetchOptions
Dim fetchResponse As BANanoFetchResponse        
Dim Error As String
        
fetchOptions.Initialize
fetchOptions.Method = "GET"
fetch.Initialize("http://cep.republicavirtual.com.br/web_cep.php?cep=30130003&formato=json", fetchOptions)
Try
        ' wait for the response
        fetchResponse = BANano.Await(fetch)
        ' wait for the json part of the response
        Log(BANano.Await(fetchResponse.Json))        
Catch(Error)
        Log(Error)
End Try

Result:


Alwaysbusy
 

Mashiane

Expert
Licensed User
Longtime User
SDUIFetch - Fixed

issue was: banano.Await(postal.GetWait) internals

B4X:
Dim postal As SDUIFetch
    postal.Initialize("http://cep.republicavirtual.com.br/web_cep.php")
    'add a parameters
    postal.AddParameter("cep", "30130003")
    postal.AddParameter("formato", "json")
    'execute the get
    banano.Await(postal.GetWait)
    Log(postal.Status)
    Log(postal.StatusText)
    Log(postal.Success)
    Log(postal.Response)




NB: Patch now available for download.
 
Last edited:

asales

Expert
Licensed User
Longtime User
1 - I don't see the logs in the IDE : Log(params.Get("parameter1")).
Even in the SithasoDaisy demo - like the sub btncode_click - I can't see the logs.
The answer to my question: the logs are not show in the Logs tab of the B4J IDE, but in the console of the browser.
In the Microsoft Edge I open the console with Ctrl+Shift+J.
 

asales

Expert
Licensed User
Longtime User
Now as I can see the logs, I get this message when I try the code.:
B4X:
Mixed Content: The page at 'https://localhost/sithasodrawer/index.html' was loaded over HTTPS, but requested an insecure resource 'http://cep.republicavirtual.com.br/web_cep.php?cep=30130003&formato=json'. 
This request has been blocked; the content must be served over HTTPS.
How can I access the insecure HTTP://?
Thanks for all help in this thread!
 

alwaysbusy

Expert
Licensed User
Longtime User
How can I access the insecure HTTP://?
As far as I know this is not possible any more for obvious security reasons. A https site can no longer access insecure http resources. Their https certificate seems to be only valid if coming from a *.uni5.net, uni5.net domain.
 

asales

Expert
Licensed User
Longtime User
The SDUIFullCalendar component is great, but:

1- I can translate the month, week, days and buttons use the locale property:

but I could not translate this button ("today"):


2 - If I resize the browser or access the calendar using a mobile, it don't show correctly:
mobile


desktop
 

asales

Expert
Licensed User
Longtime User
I'm trying to load a text file and read his lines (one by one) as a list.
This is my code to read the file and get the lines, but "myText.Get(i)" get char by char instead line by line.
B4X:
Dim myText As List = banano.Await(banano.GetFileAsText(fp, Null, "UTF-8"))
For i = 0 To myText.Size -1
    Log(myText.Get(i))   'show char by char instead line by line
Next
How I can read the text file line by line?
Thanks in advance for any tips.
 

angel_

Well-Known Member
Licensed User
Longtime User
Try this:

B4X:
Dim myStrText As String = banano.Await(banano.GetFileAsText(fp, Null, "UTF-8"))
Dim myText As List = BANano.Split(CRLF, myStrText)
For i = 0 To myText.Size -1
    Log(myText.Get(i))
Next
 

asales

Expert
Licensed User
Longtime User
It worked. Thanks!
 

asales

Expert
Licensed User
Longtime User
I'm trying to hide this component (SDUIRadioGroup) in runtime, with the code below, but the caption is not hide:
B4X:
radGender.Hide

How can I hide the caption too?
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
B4X:
Sub ShowRadio(RadioID As String)
    BANano.GetElement($"#${RadioID}_formcontrol"$).RemoveClass("hidden")
End Sub

Sub HideRadio(RadioID As String)
    BANano.GetElement($"#${RadioID}_formcontrol"$).AddClass("hidden")
End Sub

Please use this for now, will be fixed in the next release. Thank you.
 

sdleidel

Active Member
Licensed User
Longtime User
I have a Question:
i have this PHP-code to "download" a file from the Server"


php:
function getmyfile($path, $filename) {
 
$file = $path."/".$filename;

header('Content-type: application/octet-stream');
header("Content-Type: ".mime_content_type($file));
header("Content-Disposition: attachment; filename=".$filename);
while (ob_get_level()) {
    ob_end_clean();
}
readfile($file);

}

This code is OK

Now, how i can get this working in my "Sithaso APP" ?
I have test with:
test:
Dim s As String = banano.CallInlinePHPWait("getmyfile", CreateMap("mypath":"C:/laragon/www/PDFBestellung", "myfile":"Bestellung"&myLieferscheinnr&".pdf"))

But i would like that the browser download the file ...
 

Mashiane

Expert
Licensed User
Longtime User
If you can get the "blob" of the file, you can execute..

B4X:
SDUIShared.DownloadBlob(blobOfFile, "Bestellung"&myLieferscheinnr&".pdf")
 

asales

Expert
Licensed User
Longtime User
I tried this way, but don't worked:
B4X:
HideRadio("radGender")
 

asales

Expert
Licensed User
Longtime User
Can I set a max lenght to the text of the SDUITextArea?
I don't want the user put more the 500 characters in the textfield, for example.
 

asales

Expert
Licensed User
Longtime User
One more to my question list:
- Everytime that I deploy a project, it create this files in the assets subfolder of www:
600by600.jpg, SithasoDaisyLogo.jpg, daisyui.jpg, .woff2 and .ttf extension files.

I don't use this files and it is don't in the assets folder of my project.
How can I remove this files automatically when I compile the project?

Thanks in advance.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…