Source language: Translate to:

Pasar variables de una pagina a otra, se puede?

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

Pasar variables de una pagina a otra, se puede?

Postby gusgusl » Sat Mar 07, 2015 1:17 pm

Estoy creando una aplicacion y mi pregunta es como le hago para pasar los valores de una variable determinada a otra pagina de la misma aplicacion.
Lo que hago es lo siguiente:

Math "2015+1" -1 [Año2]
Math "2015+2" -1 [Año3]
Math "2015+3" -1 [Año4]
SetVar [Año1] 2015
GotoPage "SeleccionAño"

Y en la siguiente pagina simplemente hay unos botones que contienen como "Caption" el valor de estas variables
gusgusl
 
Posts: 254
Joined: Fri Mar 12, 2010 12:44 pm

Re: Pasar variables de una pagina a otra, se puede?

Postby Gaev » Sat Mar 07, 2015 5:12 pm

gusgusl:

Put this code in the page-enter code section of the page where the buttons are located ...
Code: Select all
SetObjectHTML "PushButtonX1" "[Año1]"
SetObjectHTML "PushButtonX2" "[Año2]"
SetObjectHTML "PushButtonX3" "[Año3]"
SetObjectHTML "PushButtonX4" "[Año4]"
... just replace the values of PushButtonX1 to PushButtonX4 to correspond with the ObjectId's in your App.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Pasar variables de una pagina a otra, se puede?

Postby gusgusl » Sat Mar 07, 2015 5:34 pm

esta es la unica manera de pasar el valor de una pagina a otra? o es porque esta en face Beta? no se puede mantener el valor a traves de toda la aplicacion como en neobook?
gusgusl
 
Posts: 254
Joined: Fri Mar 12, 2010 12:44 pm

Re: Pasar variables de una pagina a otra, se puede?

Postby Gaev » Sat Mar 07, 2015 6:33 pm

gusgusl:

Translation ...
This is the only way to pass the value from one page to another ? Or is it because this en face Beta? can not maintain the value through the entire application and NeoBook ?

The value (i.e. variable) is globally available ... but (I believe) the object only exists when its page is in view ... so you have to request change to its properties (like the caption of the button) when its page is being displayed.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Pasar variables de una pagina a otra, se puede?

Postby luishp » Sun Mar 08, 2015 2:11 am

gusgusl, el problema está en el nombre de las variables. Sustituye la "Ñ".
Esto no creo que sea culpa de NeoAppBuilder, sino de JavaScript.
Lo que dice Gaev es cierto, pero si es posible utilizar las variables entre pa´ginas tal y como estás intentándolo sin ningún problema.
Tampoco es recomendable utilizar guiones u otros símbolos especiales para nombrar variables y objetos.

Quick translation:

The problem is in the "Ñ" symbol.
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 361
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: Pasar variables de una pagina a otra, se puede?

Postby Gaev » Sun Mar 08, 2015 5:47 am

luishp:

The problem is in the "Ñ" symbol.

I tried it with variable [Ano1] ... same result ... SetObjectHTML "PushButtonX1" "[Ano1]" ... only changes the caption of the PushButton when the command is invoked from the same page as the PushButton.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Pasar variables de una pagina a otra, se puede?

Postby luishp » Sun Mar 08, 2015 6:10 am

This is quite strange. For me it's working fine, but only avoiding "Ñ" character.
I don't need to use SetObjectHTML wich works as you say, just the [varname]

Published:
http://sinlios.com/apps/test

Source:
http://sinlios.com/apps/test/prueba.neoapp
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 361
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: Pasar variables de una pagina a otra, se puede?

Postby Gaev » Sun Mar 08, 2015 6:43 am

luishp:

I don't need to use SetObjectHTML wich works as you say, just the [varname]

Confirmed ... if I specify [Ano1] for the Caption property of the PushButton, it works ... looks like just the SetObjectHTML command needs to be invoked on the same page ... @Dave: bug or by design ?
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Pasar variables de una pagina a otra, se puede?

Postby gusgusl » Sun Mar 08, 2015 9:22 am

Hola, hize la prueba de cambiar la letra "ñ" como dice Gaev y funciono perfectamente ahora.
Ahora mi pregunta es si existe manera de usar alguna variable predifinida ya como en el caso de Neobook es la variable [Year] para que me de el año actual sin tener que ingresarla manualmente al programar la aplicacion.
gusgusl
 
Posts: 254
Joined: Fri Mar 12, 2010 12:44 pm

Re: Pasar variables de una pagina a otra, se puede?

Postby luishp » Sun Mar 08, 2015 10:23 am

Con este código creas las variables [Day] [Month] y [Year]:
With this code you generate [Day] [Month] & [Year] vars:

Code: Select all
BeginJS
  var fechaActual = new Date()
  $rootScope.Day = fechaActual.getDate();
  $rootScope.Month = fechaActual.getMonth() + 1;
  $rootScope.Year = fechaActual.getFullYear();
EndJS
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 361
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: Pasar variables de una pagina a otra, se puede?

Postby Neosoft Support » Mon Mar 09, 2015 12:36 pm

Variables used in NeoAppBuilder must be compatible with JavaScript. The general rules for JavaScript variable names are:

Names can contain letters*, digits, underscores, and dollar signs
Names must begin with a letter
Names can also begin with $ and _
Names are case sensitive ("MyVar" and "myvar" are different variables)
JavaScript keywords cannot be used as variable names

*It appears that JavaScript permits variable names containing extended/Unicode characters like "ñ", but AngularJS does not. (I'm still researching this.)

... looks like just the SetObjectHTML command needs to be invoked on the same page ... @Dave: bug or by design ?


If you use a variable for your object's caption/text then changes will be retained when switching pages. If you modify and object using SetObjectHTML, SetAttribute or via JavaScript then changes will be lost. This is because only one page can reside in memory at a time. When you leave a page, it's objects are released from memory to make room for the new page's objects. Any changes made to those objects are lost. This is how HTML works. Sometimes it's helpful and sometimes it's not. There may be ways to compensate for this behavior - I'm looking into them.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 1 guest