Send json in a delete request

I need to send a JSON to the API. It is a delete request. With the POST I don’t have any problems but here I do…

  delReq(req: IReq): Observable<IReqResponse> {
    const url= this.utils.surl;
    return this.http.delete<IReqResponse>(url, JSON.stringify(req))
      .pipe(catchError(this.handleError<IReqResponse>('delReq'))
    );
  }

Appears “No overload matches this call”

Typeorm trying to update non-existing entity

So I’m trying to run this code:

const entities = await this.repository.createQueryBuilder(User)
      .leftJoinAndSelect(`User.photos`, 'photos') // One-to-many
      .leftJoinAndSelect('photos.status', 'photoStatus') // One-to-one
      .where('photoStatus.status = :status', { status: PhotoEnum.READY_TO_SEND })
      .getMany();

And then performing some operations to update status inside PhotoStatus entity for every user. Assume that I have updated status to new one and then I’m running this code:

    const userEntities = aggregates.map(aggregate => aggregate.userEntity);
    if (tr) {
      await tr.save(userEntities);
      return;
    }
    await this.repository.save(userEntities)

In my database I have one user with two photos and only first photo has status inside and another one doesn’t have. When I’m logging userEntities, I see one entity with one photo attached. But when I’m running save for these entities batch, I’m encountering that typeorm also trying to update another photo, that don’t have status. It cause a lot of problems and the thing is that I cannot filter out this “invinsible” photo in my aggregate. What can be the solution here? I don’t want to filter them after query

I wrote this part-time solution, but I want to get all required users with photos from query.

const trueEntity = userEntities.filter((e) => {
      const entity = e.photos.find((t) =>
        t.photoStatus?.status === PhotoEnum.READY_TO_SEND);
      if (entity) {
        return e;
      }
    });

Print Label With Labelwriter 450 In Laravel

I want to print label in Laravel with data coming dynamic and i want to use LabelWriter 450 for this purpose width: 89mm; height: 41mm; how can i do that?

i try following code but it open full page for printing not according to size

 <style>
        @media print {
            body * {
                visibility: hidden;
            }

            .label,
            .label * {
                visibility: visible;
            }

            .label {
                width: 89mm;
                height: 41mm;
            }
        }
    </style>
</head>

<body>
    <div id="labelContent" class="label">
        <button type="button" class="btn btn-info" id="printButton" onclick="printLabel()">Print</button>

        <h3>Order ID: {{ $repair->id }}</h3>
        <p>Client ID: {{ $repair->user->id }}</p>
        <p>Order Date: {{ $repair->created_at->format('Y-m-d') }}</p>
        <p>Fault: {{ $repair->selected_issues }}
        </p>
        <p>Pin/Password: {{ $repair->password }}</p>
        <p>Authorize For Reset: {{ !empty($repair->authorization) ? 'Yes' : 'No' }}</p>
    </div>
    <script>
        function printLabel() {
            window.print();
        }

    </script>
</body>

what should i try now to print with specific width and height

I’ve got a GridView in my yii2 project and I want to make the list of rows sortable

Please note that I am doing this with JavaScript and Jquery, I did not download any 3rd party extensions. And I’ve actually done this before so I’m not really sure why it’s not working.

This is my JS code:

<script>
$(document).ready(function() {
    $('tbody').sortable({
        items: 'tr',
        cursor: 'move',
        update: function(event, ui) {
            var ids = [];
            $('tbody tr').each(function() {
                var id = $(this).data('key');
                if(id !== undefined && id !== null && id !== '') {
                    ids.push(id);
                }
            });
            console.log(ids);

            $.ajax({
                type: 'POST',
                url: '/index.php?r=admin/case/updateorder&ids=' + ids + '',
                data: { ids: ids, _csrf: '<?= Yii::$app->request->csrfToken ?>' },
                success: function (data) {
                    // Handle success if needed
                },
                error: function () {
                    // Handle error if needed
                }
            });
        }
    });
});

</script>

And this is the function in my controller:

public function actionUpdateorder($ids)
{
    $array = explode(",", $ids);
    $count = count($array);
    $i = 1;
    if (isset($data['ids'])) {
        $ids = $data['ids'];
        $array = explode(",", $ids);
        $count = count($array);
        $i = 1;

        foreach($array as $id) {
            $model = CaseTask::findOne($id);
            if ($model !== null) {
                $model->order = $i;
                $model->save();
                $i++;
            }
        }

        Yii::$app->response->format = yiiwebResponse::FORMAT_JSON;
        return ['success' => true];
    } else {
        Yii::$app->response->setStatusCode(400);
        return ['error' => 'Invalid request. Missing ids parameter.'];
    }
}

The sort functionality in the gridview actually works perfectly but everytime I sort I am getting this error:

Invalid Argument – yiibaseInvalidArgumentException
Response content must not be an array.

Because of it my sort data in my order column in my db is not saving. Anyone know what the problem is??

I tried transferring my data with JSON but that always returns null for me for some reason that is why i’ve resorted to trying to send my array through the URL, but I think that is the problem.

Cannot iterate through elements in JS [closed]

I am saving links as string into a array.

When I print the whole array, I prints out all the values:
enter image description here

When I try to access individual values, I just get ‘undefined’.
Eg: console.log(“First element: ” + WhatsappLinks[0]); returns First element: undefined

I save the values in the array using WhatsappLinks.push(/string value here/);

What am i doing wrong? WhatsappLinks.length also returns zero.

Tried iterating the array using a foreach function, but that also doesnt work.

After code signing and notarizing, my program that builds with electron-builder not opening.(MacOS ARM)

enter image description here

if I open from terminal:

open TopCreator.app
The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 “Launch failed.” UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600002205530 {Error Domain=NSPOSIXErrorDomain Code=153 “Unknown error: 153” UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}

I tried to add this:

require('dotenv').config();
const fs = require('fs')
const path = require('path')
const electron_notarize = require('electron-notarize');

module.exports = async function (params) {
    if (process.platform !== 'darwin') {
        return console.log('Platform si now MacOS')
    }

    let appId = '***'

    let appPath = path.join(
        params.appOutDir,
        `${params.packager.appInfo.productFilename}.app`
    )
    if (!fs.existsSync(appPath)) {
        console.log('File not exist')
        return
    }

    console.log(`Notarizing ${appId} found at ${appPath} with Apple ID ${process.env.APPLE_ID}`)

    try {
        await electron_notarize.notarize({
            appBundleId: appId,
            appPath: appPath,
            appleId: process.env.APPLE_ID,
            appleIdPassword: process.env.APPLE_ID_PASSWORD
        })
    } catch (error) {
        console.error(error)
    }

    console.log(`Done notarizing ${appId}`)
}

it notarize succesfully, but program not opening.

adminjs, update mongoDB with custom component in list

Could not understand what is wrong while trying to update a param of an object in DB through custom component in adminjs. Receiving

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Probably need something additional with data manipulation on mongoDB. Can’t understand what exactly with this custom actions. Maybe someone can help with this

index.js

import AdminJS from "adminjs"
import { buildRouter as AdminJSExpress } from "@adminjs/express"
import express from "express"
import mongoose from "mongoose"
import * as AdminJSMongoose from "@adminjs/mongoose"

import { componentLoader } from "./componentLoader.js"
import { OfferStatus } from "./offerStatus.js"

const PORT = 3000
const DB = "..."

AdminJS.registerAdapter({
  Resource: AdminJSMongoose.Resource,
  Database: AdminJSMongoose.Database,
})

const startAdminJS = async () => {
  try {
    await mongoose.connect(DB, {
      useNewUrlParser: true,
      useUnifiedTopology: true,
    })
    console.log("Connected to MongoDB")

    const app = express()

    const admin = new AdminJS({
      resources: [OfferStatus],
      componentLoader: componentLoader,
    })

    const adminRouter = AdminJSExpress(admin)

    app.use(admin.options.rootPath, adminRouter)
    admin.watch()

    app.listen(PORT, () => {
      console.log(
        `Listening on port ${PORT}, AdminJS server started on URL: http://localhost:${PORT}${admin.options.rootPath}`
      )
    })
  } catch (error) {
    console.error("Error starting AdminJS", error)
  }
}

startAdminJS()

entity

import mongoose from "mongoose"

const orderSchema = new mongoose.Schema({
  network_id: {
    type: Number,
    required: true,
  },
  offer_status: { type: Boolean, required: true },
})

export const Order = mongoose.model("Order", orderSchema)

resource options

import { Order } from "./order.entity.js"
import { Components } from "./componentLoader.js"

const toggleStatusAction = {
  name: "toggleStatus",
  actionType: "record",
  isVisible: true,
  handler: async (request, context) => {
    const { record, resource } = context
    if (record.isValid() && record.param("offer_status") !== undefined) {
      await resource.update(request.params.recordId, {
        offer_status: !record.param("offer_status"),
      })
      return {
        record: record.toJSON(),
        notice: {
          message: "Status successfully toggled",
          type: "success",
        },
      }
    } else {
      throw new AdminJS.ValidationError(
        {
          offer_status: {
            message: "Status could not be toggled",
          },
        },
        {
          message: "An error occurred during status toggle",
        }
      )
    }
  },
  components: {
    list: Components.CustomCheckbox,
  },
}

export const OfferStatus = {
  resource: Order,
  options: {
    properties: {
      _id: {
        type: "string",
        isVisible: {
          edit: false,
          show: false,
          list: false,
          filter: false,
        },
      },
      offer_status: {
        type: "boolean",
        components: {
          list: Components.CustomCheckbox,
        },
      },
    },
  },
  actions: {
    toggleStatus: toggleStatusAction,
  },
}

custom component

import React, { useState } from "react"
import { CheckBox } from "@adminjs/design-system"

const CustomCheckbox = ({ record, property }) => {
  const [checked, setChecked] = useState(record.params[property.name])

  const handleChange = async () => {
    const newValue = !checked
    setChecked(newValue)

    try {
      await fetch(
        `/admin/api/resources/Order/records/${record.id}/toggleStatus`,
        {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            recordId: record.id,
          }),
        }
      )
    } catch (error) {
      console.error("Error to change status", error)
      setChecked(!newValue)
    }
  }

  return <CheckBox checked={checked} onChange={handleChange} />
}

export default CustomCheckbox

The Ribbon Workbench Enable rule is not firing only when Group By is applied on an editable grid

I am currently experiencing following issue and would greatly appreciate any assistance. Thanking you in advance.

Issue Description:

  • The Ribbon Workbench Enable rule is not firing only when Group By is applied on an editable grid.
  • The enable rule fires in all other cases, such as for single-record selection and even for multiple-record selection(Select All) when Group By is not applied.
  • Surprisingly, it also works for single-record selection manually even when grouping is applied, but it does not work only for ‘Select all’ selection when grouping is applied.
  • Note: The editable grid is formed by applying the Editable Grid component on a normal Subgrid.

Detailed Explanation:

  • I’ve added an ‘Approve’ button to the editable subgrid using Ribbon Workbench. 
  • The visibility logic of the button is controlled by an enable rule, which involves a Custom Rule calling JavaScript logic. 
  • The visibility works seamlessly with both normal subgrids and editable subgrids, except in one scenario where Group By is applied to the editable grid.
  • In the working scenario, when all records are selected in the editable grid and Group By is set to ‘no Grouping,’ the ‘Approve’ button is visible. Deselecting all records hides the ‘Approve’ button.
  • However, in a non-working scenario, when all records are selected in the editable grid and Group By is set to ‘Start Date,’ the ‘Approve’ button should be visible, but it remains hidden. The issue lies in the enable rule not getting fired in this case, specifically when Group By is applied to ‘Start Date.’

respond write function in Server Sent Event api not writing back to client

I am writing a persistent real time application that consumes a Server Sent Event API. I am using NodeJS as listening client and another NodeJS as SSE api that act as a server. The both api worked as expected as the client api consumed and receives persistent message from the SSE Server but there are some logical errors.

***The Problem

a) Inside the Server Sent Event api route “/sample/api/v1/test”, the respond write function message inside the set Interval function was not executed but if there is any syntax error inside the set Interval function, it would be detected but it was not writing message back to the listening client using the response write function when inside the set Interval.

b) The callback function inside the transporter send Mail function, the conditional checking of the callback function(error, response) to know if email is sent or not does not send response write function back to the client but it sent console log message to the console of the SSE server running the api.

I am concerned why response write was not sent inside set interval function and inside the transporter send Mail call back function.

// *** THE SERVER SENT EVENT

const express = require("express");
const app = express();
const cors = require('cors');
const bodyParser = require('body-parser');
const nodemailer = require('nodemailer');
const http = require("http");    //DEVELOPMENT PROCESS
const https = require('https'); 

var corsOptions = {  
  origin: 'http://127.0.0.1:3001',
  methods: ["GET","HEAD","PUT","PATCH","POST","DELETE"],  
};

 let emailSenderOptions = (to, subject, htmlToSend, fromEmail) =>{
  return mailOptions = {
   from: fromEmail,
   to : to,
   subject : subject,
   html : htmlToSend   
};
}


app.post('/sample/api/v1/test', (req, res) => {

res.writeHead(200, {
        'Content-Type': 'text/event-stream',
        Connection: 'keep-alive',
        'Cache-Control': 'no-cache',
    });

//this set timeout is not executed and not delaying for 10secs here
setTimeout(function () {
  console.log("Please wait");
}, 10000);


/* The compiler is not executing the res.write message inside the setInterval. I want everything to be sent to client API every 5 seconds.*/

setInterval(() => {
  res.write("Server: API Found");

  res.write(`nConnected at ${new Date()} n n`);

transporter.sendMail(emailSenderOptions(emailSenderOptions("[email protected]", "SAMPLE SUBJECT", "This is a sample as a letter body", "[email protected]"), function (error, response) {
    if (error) {
          
          //for an email that is not sent, this line is not sent to nodejs client
          res.write(`Email could not be sent`);

         /* for an email that is not sent, this line is successfully logged to the console.log of running nodejs server. It means that this line is executed but why is the res.write() not executed or sent to nodejs api*/

         console.log(chalk.red(`Email could not be sent.`));        
    }

    else{
          
         //for an email that is successfully sent, this line is not sent to nodejs client

         res.write(`Email has been sent.`);


    /* for an email that was successfully sent, this line is successfully logged to the console.log of running nodejs server. It means that this line is executed but why is the res.write() not executed or sent to nodejs api*/

         console.log(chalk.green(`Email has been sent`));
    }
}); 


}, 5000);


// compiler only executes the res.write message and send back to listening client from here

  res.write(`nConnected at ${new Date()} n`);

  res.write(`Only from here is sent back to listening client.  n n`);

transporter.sendMail(emailSenderOptions("[email protected]", "SAMPLE SUBJECT", "This is a sample as a letter body", "[email protected]"), function (error, response) {
    if (error) {
          
            //for an email that is not sent, this line is not sent to nodejs client
          res.write(`Email could not be sent`);

         /* for an email that is not sent, this line is successfully logged to the console.log of running nodejs server. It means that this line is executed but why is the res.write() not executed or sent to nodejs api*/

         console.log(chalk.red(`Email could not be sent.`));        
    }

    else{
          
         //for an email that is successfully sent, this line is not sent to nodejs client

         res.write(`Email has been sent.`);


    /* for an email that was successfully sent, this line is successfully logged to the console.log of running nodejs server. It means that this line is executed but why is the res.write() not executed or sent to nodejs api*/

         console.log(chalk.green(`Email has been sent`));
    }
}); 

});

================================NODEJS CLIENT

const express = require("express");
const app = express();
const http = require('http');
const https = require('https');
const fs = require("fs");
const checkinternetconnected = require('check-internet-connected');
const axios = require('axios');
var EventSource = require('eventsource');


app.use(express.json()); 

var server = http.createServer(app);

var connected = true;

const requestService = () =>{  

  var url = `/sample/api/v1/test`

  let payload = {
    username: username,
  };
  
  axios({
    url: url,
    method: 'post',
    data: payload
  })
  .then(function (response) {
      // your action after success
      console.log(response.data);
  })
  .catch(function (error) {
     // your action on error success
      console.log(error);
  });
}

const persistentRespond = (req, res) => {
  try {
    const e = new EventSource('http://127.0.0.1:3002/xc3113n77001z/api/v1/subscribe');

      e.addEventListener("Server Respond: ", (e) => {
        const data = e.data;

       // Your data
        console.log(`${data}`)
        
    })
    
res.on('close', () => {
        e.removeEventListener("Server Closed", (e) => {
      });
    })
  } catch (err) {
    console.log(err)
  } 
}


server.listen(port, host);
server.on('listening', function() {
    console.log(`Waiting for respond from server application n n `);

requestService();

persistentRespond();

});

***What I expected

  1. I wanted response write function to write message to the listening client every 5 seconds from inside set interval function.

  2. I wanted to write back to the listening client from transporter send mail function call back function if the email was sent or not.

In Winwheel.js using calculatePrize result when finish the whell

I am working on Winwheel.js for draw. Everything works fine but I’m stuck somewhere. When the wheel is turned, I get some datas with axios from back and the result is determined. I want to use this response when the wheel is stopped, I tried many of things but I didn’t do it.

let theWheel = new Winwheel({
                //wheel settings//       
                'segments'        :             
                [                               
                   {'fillStyle' : '#008000', 'text' : '150 Coin', 'textFontSize' : 13, 'textFillStyle' : '#ffffff'},
                   ...,    

                ],
                'animation' :          
                {
                    'type'     : 'spinToStop',
                    'duration' : 10,    
                    'spins'    : 3,    
                    'callbackFinished' : alertPrize,
                    'callbackSound'    : playSound,  
                    'soundTrigger'     : 'pin'        
                },
                'pins' :                // Turn pins on.
                {
                    'number'     : 10,
                    'fillStyle'  : 'silver',
                    'outerRadius': 4,
                }
            });
async function calculatePrize(){
                let result = await axios.post("/draw-reward-win-wheel/", {}).then((response) => {
                let stopAt;
                if(response.data.text == '150') stopAt = (1 + Math.floor((Math.random() * 30)));
                //Other possibilities

                theWheel.animation.stopAngle = stopAt;

                 theWheel.startAnimation();
            }).catch((err) => {
                console.log(err);
            });

    }

            async function alertPrize(code)
            {
                //I need response.data.text here
            }

Frozen Columns in JSF Primefaces

I would like to freeze columns in jsf using js, i.e. I want by using one scroll all tables to move and the name column to move with it , currently it works for me only on the main table and in the tables in <row:Expansion/> no longer. For each name column in each table there is an added class .frozen-column with positon:Sticky; please help.
enter image description here
enter image description here

        <h:form id="budgetReportByLocationForm">
            <div class="grid table-demo">
                <div class="col-12">
                    <div class="card">
                        <div class="flex justify-content-between align-items-center mb-2">
                            <div class="flex justify-content-center align-items-center">
                                <h4 style="margin: 0!important;">Planowanie Budżetu #{budgetPlanBean.budgetYear} - #{budgetSessionScope.budgetPlanLocationName}</h4>
                                <p style="margin-left: 10px; color: #1b74c5; font-weight: bold;">Limit Budżetu: #{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.budgetLimit)}</p>
                            </div>
                            <div>
                                <h:outputText value="Opcje:" styleClass="mr-2"/>
                                <p:menuButton icon="pi pi-ellipsis-v" styleClass="rounded-button">
                                    <p:submenu label="Generuj plik" icon="pi pi-file">
                                        <p:menuitem value="XLS" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="xls"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>

                                        <p:menuitem value="XLSX" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="xlsxstream"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>

                                        <p:menuitem value="PDF" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="pdf"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>

                                        <p:menuitem value="CSV" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="csv"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>

                                        <p:menuitem value="XML" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="xml"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>
                                    </p:submenu>
                                    <p:menuitem value="Edytuj informacje o budżecie"  oncomplete="PF('budgetEditBudgetDialog').show()" process="@this" update="messages"  icon="ui-icon-pencil"/>

                                </p:menuButton>
                            </div>
                        </div>
                        <p:dataTable
                                var="budgetPlan" rowIndexVar="lp" id="tableBudgetReportObject"
                                editable="true" widgetVar="datatableVarBcg"
                                rowKey="#{budgetPlan.budgetPositionId}"
                                showGridlines="true"
                                emptyMessage="Brak elementów"
                                value="#{budgetPlanBean.budgetValues.budgetPositionList}">
                            <p:ajax event="rowToggle"
                                    listener="#{budgetPlanBean.updateBudgetPlanMap(budgetPlan.budgetPositionId)}"/>
<!--                            <p:ajax update="messages" action="#{budgetPlanBean.checkBudgetLimit}" event="load"/>-->
                            <div class="linked">
                                <p:columnGroup type="header">
                                    <p:row>
                                        <p:column rowspan="2" headerText="Lp."
                                                  style="width:20px;!important;" styleClass="frozen-column"/>
                                        <p:column colspan="2" headerText="Nazwa grupy kosztowej"
                                                  style="width:300px;!important; position: sticky!important; background-color: #f8f9fa; "
                                                  styleClass="frozen-column"/>
                                        <p:column colspan="2" headerText="Edycja" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="MPK"
                                                  style="width:100px;!important; background-color: #f8f9fa; "/>
                                        <p:column colspan="2" headerText="Suma roczna" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Styczeń" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Luty" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Marzec" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Kwiecień" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Maj" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Czerwiec" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Lipiec" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Sierpień" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Wrzesień" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Październik" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Listopad" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Grudzień" style="width: 100px!important;"/>

                                    </p:row>
                                    <p:row>
                                        <p:column colspan="2" headerText="Suma" style="width: 300px!important;"
                                                  styleClass="frozen-column"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" headerText="" style=""/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" headerText="" style=""/>
                                        <p:column styleClass="columnBcgOdd" colspan="2"
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.yearValue)}"
                                                  style="color: #{budgetPlanBean.isBudgetLimitExceededSum() ? 'red' : 'inherit'};"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[0])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[1])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[2])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[3])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[4])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[5])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[6])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[7])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[8])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[9])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[10])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[11])}"/>
                                    </p:row>
                                </p:columnGroup>

                                <p:column style=" width: 20px!important;" styleClass="frozen-column">
                                    <h:outputText value="#{lp+1}"/>
                                </p:column>

                                <p:column style="width:300px;!important; " styleClass="frozen-column" colspan="2">
                                    <p:rowToggler rendered="#{not budgetPlan.last}"/>
                                    <h:outputText value="#{budgetPlan.budgetPositionName}"/>
                                </p:column>
                                <p:column rendered="#{not budgetPlan.last}" style="width: 100px!important;"
                                          colspan="2"/>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="width: 100px!important;"
                                          rendered="#{budgetPlan.last}">
                                    <div style="display: flex!important; justify-content: center!important; align-items: center!important;">
                                        <p:commandButton icon="pi pi-pencil"
                                                         styleClass="rounded-button ui-button-flat ui-button-flat"
                                                         onclick="PF('openingPlanEdit').show()"
                                                         process="@this"
                                                         update="dialogForm messages"
                                                         actionListener="#{budgetPlanBean.initUpdateBudgetPlanPosition(budgetPlan)}"

                                        />
                                        <p:commandButton icon="pi pi-times"
                                                         styleClass="rounded-button ui-button-danger ui-button-flat"
                                                         process="@this"
                                                         ajax="false"
                                                         update="budgetReportByLocationForm"
                                                         actionListener="#{budgetPlanBean.clearBudgetPlanPosition(budgetPlan)}"
                                                         onstart="return confirm('Czy na pewno chcesz wyzerować?')"/>
                                    </div>

                                </p:column>
                                <p:column style="width:100px;!important; " colspan="2">
                                    <h:outputText value="#{budgetPlan.budgetPositionMpk}"/>
                                </p:column>
                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.yearValue)}"/>
                                </p:column>
                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[0])}"/>
                                </p:column>
                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[1])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[2])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[3])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[4])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[5])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[6])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[7])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[8])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[9])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[10])}"/>

                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[11])}"/>
                                </p:column>

                            </div>


                            <p:rowExpansion rendered="#{not budgetPlan.last}">
                                <p:dataTable value="#{budgetPlanBean.budgetPlanMap.get(budgetPlan.budgetPositionId)}"
                                             rowKey="#{budgetPlan2.budgetPositionId}"
                                             emptyMessage="Brak elementów"
                                             styleClass="linked"
                                             showGridlines="true"
                                             id="tableBcge" var="budgetPlan2" rowIndexVar="lp">
                                    <p:ajax event="rowToggle"
                                            listener="#{budgetPlanBean.updateBudgetPlanMap(budgetPlan2.budgetPositionId)}"/>
                                    <div class="linked">
                                        <p:column style="" styleClass="frozen-column">
                                            <h:outputText value="#{lp+1}"/>
                                        </p:column>

                                        <p:column style="width:300px;!important; margin-left: 0!important; "
                                                  styleClass="frozen-column" colspan="2">
                                            <p:rowToggler rendered="#{not budgetPlan2.last}"/>
                                            <h:outputText value="#{budgetPlan2.budgetPositionName}"/>
                                        </p:column>
                                        <p:column rendered="#{not budgetPlan2.last}" style="width: 100px!important;"
                                                  colspan="2"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2"
                                                  style="flex-direction: column!important; width: 100px!important;"
                                                  rendered="#{budgetPlan2.last}">
                                            <div style="display: flex!important; justify-content: center!important; align-items: center!important;">

                                                <p:commandButton icon="pi pi-pencil"
                                                                 styleClass="rounded-button ui-button-flat ui-button-flat"
                                                                 onclick="PF('openingPlanEdit').show()"
                                                                 process="@this"
                                                                 update="dialogForm messages"
                                                                 actionListener="#{budgetPlanBean.initUpdateBudgetPlanPosition(budgetPlan2)}"
                                                />
                                                <p:commandButton icon="pi pi-times"
                                                                 styleClass="rounded-button ui-button-danger ui-button-flat"
                                                                 process="@this"
                                                                 update="budgetReportByLocationForm"
                                                                 actionListener="#{budgetPlanBean.clearBudgetPlanPosition(budgetPlan2)}"
                                                                 onstart="return confirm('Czy na pewno chcesz wyzerować?')"/>
                                            </div>
                                        </p:column>
                                        <p:column style="width:100px;!important; " colspan="2">
                                            <h:outputText value="#{budgetPlan2.budgetPositionMpk}"/>
                                        </p:column>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.yearValue)}"/>
                                        </p:column>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[0])}"/>
                                        </p:column>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[1])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[2])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[3])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[4])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[5])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[6])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[7])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[8])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[9])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[10])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[11])}"/>
                                        </p:column>

                                    </div>

.frozen-column { position: sticky!important; left: 0!important; color: #657380!important; z-index: 997; background: #F6F9FE!important; }

I tried using the built-in frozen-column in primefaces but it was crashing my table

Rebuild or Maintain a connection between android and MySQL database

I am creating an app with a html, css, js inside a webview, and also several databases to store data. My app is designed to be used for 10 to 11 hours each time.

A big problem was found that android will kill my app in background after leaving for a while. However, app gets killed will lead to a big problem as it means the whole task has to redo again. I have to maintain OR rebuild the connection between database and android to ensure my app can keep running smoothly.

I would like to know:
1.) is there any way to maintain the connection between database and android (e.g. put it in foreground service?) so that killing app will not affect the connection?

2.) can I ask android and js to rebuild the connection (e.g. synchronize the database?) between android and js after the app get killed by OS?