How to create an HTML Form viewer using BrowserFrame component?

I am trying to create a kind of HTML form viewer using the BrowserFrame control but I am experiencing some difficulties. The main idea of our solution is that an administrator is allowed to create a template html form using a designer so that the users of the application will be able to fill-in this form and save the results in the database. You can think of our app as an embedded google forms-like system. According to our scenario the user selects a template and a new page is displayed - this page presents a new html form that is loaded into a BrowserFrame control. Our problem has to do with the fact that when the user fills in the form, we cannot get back the modified html content included into the BrowserFrame control. At the following example, we assume that we load the html form into a BrowserFrame control, the user enters some values in the form and using a button, we are trying to display into a textarea the new html content of the control. Unfortunately, the displayed content is always the same ignoring the data entered by the user. Please find below a sample of our code:

public class Formviewer extends Screen {
   BrowserFrame browserFrame;
    TextArea textArea;

    Button showContent;

    protected void onInit(InitEvent event) {

        //Here, define the structure of the web form that is displayed to the user
        //This structure will be usually stored in another database table 
        String htmlText ="<html>\n" +
                "    <head>\n" +
                "    </head>\n" +
                "    <body>\n" +
                "        <div id=\"form\"></div>\n" +
                "        <script type=\"text/javascript\">\n" +
                "            $(document).ready(function() {\n" +
                "                $(\"#form\").alpaca({\n" +
                " ............"
                "    </body>\n" +

               .setStreamSupplier(()->new ByteArrayInputStream((htmlText).getBytes()))

                StreamResource resource = (StreamResource) browserFrame.getSource();
                Supplier<InputStream> is = resource.getStreamSupplier();
                BufferedReader r = new BufferedReader(new InputStreamReader(is.get(), StandardCharsets.UTF_8));
                StringBuilder sb = new StringBuilder(8192);
                String str = null;
                while ((str = r.readLine()) != null)
                String xx = sb.toString();

            catch (IOException ioe){}


It seems that we are missing something regarding the usage of the BrowserFrame control. Do you have any idea about how we could implement this kind of functionality in CUBA.Platform? We are thinking of an alternative to post the data of the form into a REST service but we’d like to get the modified version of the form and store it into a database entry.

Thank you


BrowserFrame sources can’t be used for two-way data transfer, they are used only as sources of content. I would recommend taking a look at HtmlBox (see corresponding demo and docs), that enables you to combine HTML markup with UI components.


Thanks for your reply.

Unfortunately, this control according to the documentation does not support embedded Javascript code. That’s why I tried to use the BrowserFrame control. In our project, we have several user defined html forms that need to be displayed during runtime in order for us to get feedback from the users. For the moment, we are reviewing an alternative option based on the Orbeon forms that will be embedded into the cuba app.