B4J Question How create an HTMLView with add imagge button.

Alejandro Moyano

Licensed User
Hi i developing an native java application where user can imput text and images on an HTMLEditor (is native by its use case).
I trying to create an HTMLEditor Cutom View but the file chooser ask me for a Form, any way to handle?

Private Sub AddImage
        Dim path, fileName, fullPath, imsgStr As String
        Dim fc As FileChooser
        fc.Title="Browse and select a file"
        fc.SetExtensionFilter("Image", Array As String ("*.jpg", "*.png", "*.gif"))
        fc.InitialFileName = ""
        fullPath = fc.ShowOpen(mBase.Parent) '<- unknow  how handdle this because must be Form
        path = File.GetFileParent(fullPath)
        fileName = File.GetName(fullPath)

        'convert the image in base64
        imsgStr =  Base64EncodeDecodeImage.Base64ImageToString(path,fileName)
        ' Show it in HTMLeditor view
        EnhancedView.HtmlText = EnhancedView.HtmlText & "<p><img src=""data:image/png;base64," & imsgStr & """/></p>"
        LogError("Error trying to add an image on EnhancedHTMLView")
    End Try
End Sub


  • Add image button to HTMLEditor.zip
    5.4 KB · Views: 31


Licensed User
If it's a B4XPages project, try
 Dim s As String = fc.ShowOpen(B4XPages.GetNativeParent(Me))
In B4J it should return the Form you need.
Upvote 0

Alejandro Moyano

Licensed User
I guess that you mean B4J application.

You need to pass the form or B4XPage to the AddImage method.

How i pass the form to the custom view? I solved in an ugly way but i wanna make it something generic to improve the code and share with the forum.

And yes i'm building since 2 years an Aplicacion Lifecicle Manager, an tool where u define a SaaS system in abstract idea and its generate an beautiful documentation with UML graphs, the rest api documentacion, the python backend and the B4X App conection layer, i working in the last few tweaks before release V1.0 and beta test users wanna add their designer screenhost.

I don't use B4XPages as uses many desktop java bindings libraries and the project started before B4XPages.
Upvote 0