Android Question Calling B4XPage in "recursive" mode

Rubsanpe

Active Member
Licensed User
Hello, is it possible to call the same B4XPage from that same B4XPage? I have a page that contains an index of previous and subsequent references. Clicking on those references opens another screen with the data of that reference. From that same screen you can click on new references...

When I try to use B4XPages it does not do anything when I click on the references as it is trying to open itself again...

Thank you

Ruben
 

Rubsanpe

Active Member
Licensed User
Hi. I am passing the reference as a parameter of the B4XPage. Then it accesses the data of that reference and shows that B4XPage. In the data shown there may be another reference that when pressed calls the same B4XPage again passing it as a parameter the new reference so that the new data are shown.

This worked well using Activities and using the code that appears in https://www.b4x.com/android/forum/threads/start-activity-from-the-same-activity.52347/post-327832

This does not apply to B4XPages.

Ruben
 
Upvote 0

Rubsanpe

Active Member
Licensed User
In the B4XPage " B4XPage_BOE_Data Documento" I have event links as in

B4X:
Sub link_Click (Tag As Object)
    Dim sRef As String = Tag
    Dim sUrl As String = "https://www.boe.es/diario_boe/xml.php?id=" & sRef
    Dim mapParam As Map = CreateMap("Url":sUrl,"Subtitulo":"Datos de documento del BOE","Boletin":"BOE-BOE-","Tab":0)
    // Pass link data
    B4XPages.MainPage.pBOE_BOE_DatosDocumento.mapParam = mapParam
    B4XPages.ShowPage("B4XPage_BOE_DatosDocumento")
    
End Sub

It calls itself with other values to show the data of another reference.

Rubén
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
It's not clear to me what you are doing or what you mean by 'reference' but I guess that previously you would rely on restarting the Activity which would tear things down and create a new activity by reloading the new layout with new values. In B4XPages you will need to implement a Sub that updates your layout with the latest values. You can call it in the B4XPage_Appear event when it should be run whenever the page appears. You may need to add some logic to link_Click to identify if it is the current page that you want to be updated and call the Sub directly.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The problem is that when you reuse the B4XPage, when you close it, it no longer shows the previous contents.
Sorry, I'm totally baffled by what you mean and what you are doing. Why are you closing the page if you want to keep it's contents?
 
Upvote 0

Rubsanpe

Active Member
Licensed User
It is very simple. These are legal documents. They refer to other documents published before or after the same one (Pre- and post-references). If from the document I am looking at now I click on the reference to another document, that document must be loaded into the same B4XPage. If after viewing a document I want to go back, the previous document I linked to is no longer available, as B4XPage is the same for displaying all documents.

Rubén
 
Upvote 0

Rubsanpe

Active Member
Licensed User
Hi. I don't load the documents. I use information that describes the documents. I create a summary sheet of their properties and relationships. That's why I can go from one document to another by clicking on the links.

In any case thank you for your interest. I've redone it as Activities and it works again as it used to.

It simply cannot be done with B4xPages.

Rubén
 
Upvote 0

rraswisak

Active Member
Licensed User
There must be a solution for your issue with B4XPage, i just re-re-read your explanation but still i don't get what you wan't to achieve.
Maybe a little project which describe your issue will much better help us.

Are you using single page in this project ? Is link_Click sub reside in B4XPage_BOE_DatosDocumento page/class or not ?
If only one page, my bet that you need to create sub to display the (last) document reference that you store in
B4XPages.MainPage.pBOE_BOE_DatosDocumento.mapParam in the B4XPage_BOE_DatosDocumento class

B4X:
Sub link_Click (Tag As Object)
    Dim sRef As String = Tag
    Dim sUrl As String = "https://www.boe.es/diario_boe/xml.php?id=" & sRef
    Dim mapParam As Map = CreateMap("Url":sUrl,"Subtitulo":"Datos de documento del BOE","Boletin":"BOE-BOE-","Tab":0)
    // Pass link data
    B4XPages.MainPage.pBOE_BOE_DatosDocumento.mapParam = mapParam
    'B4XPages.ShowPage("B4XPage_BOE_DatosDocumento")  '<-- no need to open since you are in B4XPage_BOE_DatosDocumento page

    ShowDocumentLink
    
End Sub

Private Sub ShowDocumentLink
'--- your code goes here and do what you want with B4XPages.MainPage.pBOE_BOE_DatosDocumento.mapParam variable
End Sub

Its good place if you want to show data with last reference in B4XPage_Appear sub

B4X:
Private Sub B4XPage_Appear
     ShowDocumentLink
End Sub
 
Upvote 0

Rubsanpe

Active Member
Licensed User
Hi, my project was initially using Activities. Everything was running fine. I switched to using B4XPages. "B4XPage_BOE_DataDocumento" I use it to display information from a document: reference, date, keywords, previous and subsequent references, ... I initialise this B4XPage with the identifier of the document I want to view and then I open it. If I click on an ID of a document before or after the current one, "B4XPage_BOE_DataDocumento" shows me the data of that new document, but once that data has been shown I no longer have the option to see the initial document again, since "B4XPage_BOE_DataDocument" has been reused and when I click on the back arrow it no longer goes through "B4XPage_BOE_DataDocumento".

In any case, I have used Activity again to display the document information.

Thank you

Rubén
 
Upvote 0
Top