# Passing a parameter to another view

**URL:** <https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328>\
**Category:** Forum\
**Tags:** mobile\
**Created:** [February 6, 2012, 3:03pm UTC](https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328 "2012-02-06T15:03:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 6, 2012, 3:03pm UTC](https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328/1 "2012-02-06T15:03:20Z")

</div>

Hi All,

What is the best practice to pass a parameter to another view , E.g when a button is clicked.Currently we use button get/setText but I don’t think this is the right way.

Thanks  
Atanas

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 6, 2012, 5:26pm UTC](https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328/2 "2012-02-06T17:26:12Z")

</div>

Hi Atanas,

What are you referring to here when you say ‘parameter’? I imagine calling getText on a button you’ve clicked isn’t going to result in particularly useful information, for example?

Regards,

Nick.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 6, 2012, 5:36pm UTC](https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328/3 "2012-02-06T17:36:23Z")

</div>

Hi Nick,

Imagine I have a page1 which represent a list of items(each one represented as a button).I have a second view (page 2) as well and I want to pass item id from page1 to page 2 so that be able to keep track which item was clicked.

Currently it was implemented with get/setText so that when a button is clicked nUIEventCallback method that handles the sent event receive the button object with text which is the id of the item.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 6, 2012, 5:42pm UTC](https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328/4 "2012-02-06T17:42:27Z")

</div>

Hi Atanas,

I think the simpler alternative there is to reference the nuiid of the incoming object in the nUIEventCallback method. Assuming the buttons are being given incremental id’s (e.g. NUIID\_MY\_BUTTON\_ID0, NUIID\_MY\_BUTTON\_ID0 + 1, NUIID\_MY\_BUTTON\_ID0 + 2, …), you could use this value to determine which button has been pressed. What you do with this value is then obviously up to you.

Regards,

Nick.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 6, 2012, 6:12pm UTC](https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328/5 "2012-02-06T18:12:54Z")

</div>

That is quite coupled with the order of items in the list.That would work if the list of items is static but I rather meant list which is populated dynamically at runtime.What is getText property of nUIButtonElement used for?

---

<div class="post-metadata">

**Author:** ![Javier\_Gallego](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/javier_gallego/32/77_2.png) [@Javier\_Gallego](https://techcommunity.softwareag.com/u/Javier_Gallego)\
**Post date:** [February 6, 2012, 6:44pm UTC](https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328/6 "2012-02-06T18:44:44Z")

</div>

Hi Atanas  
I made it in exactly the way Nick has described. I have an array of items (populated dynamically when the item list is shown), and based on it I build a list where each button gets NUIID = (NUIID\_MY\_BUTTON\_ID0 + index) of the array item. Based on that index, when I click the button I make a transition to the “details” of the selected item.  
When I go back from details view to the item list view, I refresh the list.

Best regards  
Javier

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:01pm UTC](https://techcommunity.softwareag.com/t/passing-a-parameter-to-another-view/100328/7 "2021-04-02T15:01:51Z")

</div>


