Detecting page refresh - like we used to do in .net - Page.IsPostBack()

Detecting page refresh - like we used to do in .net - Page.IsPostBack()

This question is answered

HI all,

I have a plugin extension that gives me a set of records (from the database).

#set($Response = $MyExtension.MyMethod())

I am iterating this collection and displaying :

#foreach($item in Response)

$item

<br />

#end

----

For e.g.: The above code will display

item1

item2

item3

item4

Now, every time the page is refreshed, the list of items displayed is duplicated...:

-------

item1

item2

item3

item4

item1

item2

item3

item4

------

Note: The duplicate entries grow each time we do a page refresh.

Is there any way to detect and avoid this.?

Thank you.

Verified Answer
  • Though it may be a typo this line is syntactically incorrect:

    #foreach($item in Response)

    It should be
    #foreach($item in $Response)
     
     
    Have you debugged your extension?  What is the data coming back from your extension?  Can you provide the code in MyMethod()?
     
     
     
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: Madhu Sadlapur [mailto:bounce-Madhu_Sadlapur@communities.telligent.com]
    Sent: Tuesday, January 08, 2013 3:51 AM
    To: discussion_evolution@communities.telligent.com
    Subject: [Telligent Evolution Platform Discussion] Detecting page refresh - like we used to do in .net - Page.IsPostBack()
     

    HI all,

    I have a plugin extension that gives me a set of records (from the database).

    #set($Response = $MyExtension.MyMethod())

    I am iterating this collection and displaying :

    #foreach($item in Response)

    $item

    <br />

    #end

    ----

    For e.g.: The above code will display

    item1

    item2

    item3

    item4

    Now, every time the page is refreshed, the list of items displayed is duplicated...:

    -------

    item1

    item2

    item3

    item4

    item1

    item2

    item3

    item4

    ------

    Note: The duplicate entries grow each time we do a page refresh.

    Is there any way to detect and avoid this.?

    Thank you.

All Replies
  • Though it may be a typo this line is syntactically incorrect:

    #foreach($item in Response)

    It should be
    #foreach($item in $Response)
     
     
    Have you debugged your extension?  What is the data coming back from your extension?  Can you provide the code in MyMethod()?
     
     
     
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: Madhu Sadlapur [mailto:bounce-Madhu_Sadlapur@communities.telligent.com]
    Sent: Tuesday, January 08, 2013 3:51 AM
    To: discussion_evolution@communities.telligent.com
    Subject: [Telligent Evolution Platform Discussion] Detecting page refresh - like we used to do in .net - Page.IsPostBack()
     

    HI all,

    I have a plugin extension that gives me a set of records (from the database).

    #set($Response = $MyExtension.MyMethod())

    I am iterating this collection and displaying :

    #foreach($item in Response)

    $item

    <br />

    #end

    ----

    For e.g.: The above code will display

    item1

    item2

    item3

    item4

    Now, every time the page is refreshed, the list of items displayed is duplicated...:

    -------

    item1

    item2

    item3

    item4

    item1

    item2

    item3

    item4

    ------

    Note: The duplicate entries grow each time we do a page refresh.

    Is there any way to detect and avoid this.?

    Thank you.

  • Hi,

    There was a problem in the method logic. The variable was a class level variable. Changed the scope of it and all seems to be well now.