1

I know task node works like thread and not support dialog inside a task node. But, Is there any way to open a dialog box inside a task node. I also used getparent(). But no luck. my code is below.

url="URL is Here"
m.req=createobject("roURLTransfer")
m.req.seturl(url)
m.port=createobject("roMessagePort")
m.req.setport(m.port)
m.req.asyncgettostring()
while true    
    msg=wait(100,m.port) '100 millisecond pause
    if type(msg)="roUrlEvent" then
        if msg.getresponsecode()=200 then
            data=msg.getstring()
            headers=msg.getresponseheadersarray()
            exit while
        else
            m.req.asynccancel()
            ' Here I tried to print a dialog box
        warningdialog = CreateObject("roSGNode", "Dialog")
            warningdialog.title = "Warning"
            warningdialog.message = "Not Valid Request."
            warningdialog.buttons = ["Ok"]
            m.top.dialog = warningdialog
            m.top.dialog.observeField("buttonSelected", "warning")
        end if
    end if
end while

Here give me a warning not to exist dialog field. Is there any other option for this?

2 Answers2

0

Yes, the proper way to do it is to pass the information to trigger the dialog back to your main thread through a field on the task node; either a separately observed field or (preferably) through your normal content /data field. Then in your main thread, in the callback function, check for the error / dialog in the response and display it from there.

Basically whether your task call succeeds or fails, the calling component (that is usually already observing the task for a response) should handle displaying the response either way. make sense?

Joe T
  • 2,300
  • 1
  • 19
  • 31
  • I successfully open dialog box inside a task node or Group node using https://stackoverflow.com/questions/62676623/images-not-loaded-when-i-update-a-content-in-postergrid/62746697#62746697 this way suggests me RokuNB. – Nikunj Chaklasiya Jul 06 '20 at 06:25
0

For that, you have to add one more error field in task node and from the main thread you have to observer that field. And whenever you get the error in task node you just need to store in the error field.

Here is the example

int Task node XML You have to add the field

 <field id = "error" type = "string" />

Now whenever you get the error in Task node you just have to pass it in the error field

m.top.error = "Feed failed to load. Unknown reason."

Now in main tread XML or in HomeScene XML you have to the observer that error field

m.config_task.observeField("error", "onConfigError")

And in OnConfigError handler, you can show your error dialog

Chintan Kukadiya
  • 784
  • 5
  • 16