Welcome, Guest. Please login or register.

Login with username, password and session length
March 11, 2010, 08:54:44 pm

 

   Home   Help Search Login Register  

Pages: [1]   Go Down
  Print  
Author Topic: Troubles with the Hidden widget...  (Read 1890 times)
Nanawel
eyeOS Team
Senior User
*****
Offline Offline

Posts: 389



View Profile WWW
« on: November 21, 2007, 10:53:57 pm »

Hi everybody,

I'm developping a new application for eyeOS but I encounter some troubles to stabilize it.
After several loooong hours debugging the different points, I discovered that sometimes, when I use the setText() method on a Hidden widget, the value is not well saved!
What I find very strange is that it does not happen all the time, but randomly during the execution.

To sum up a little what I do:
I use a Hidden widget to store a serialized array. When I need a value, I unserialize the text and pick the data up. But sometimes I also need to delete a cell of the array. So I unserialize it into a variable, unset the cell I want to remove, then serialize the array again and store it in the Hidden widget.
Most of the time, it works. But sometimes, it doesn't.
So when I check if the array is empty in a next request, the cell is still here so the behaviour is not what I expect...

Did someone experience the same problem? And who do know how to solve it?

Thanks in advance
« Last Edit: November 21, 2007, 11:54:16 pm by Nanawel » Logged

Anaël
AnthongRedbeard
Junior User
**
Offline Offline

Posts: 65


View Profile
« Reply #1 on: November 23, 2007, 03:59:32 pm »

make sure you are calling setText() after Show() or else the object won't exist.

make sure it has a globallly unique name.

I have found instances where the content makes a difference in whether or not it will work. For example, the Lable widget won't allow any line returns, so I had to add something to strip them out before applying it to the widget.

-Anthong
Logged
Nanawel
eyeOS Team
Senior User
*****
Offline Offline

Posts: 389



View Profile WWW
« Reply #2 on: November 25, 2007, 04:58:22 pm »

make sure you are calling setText() after Show() or else the object won't exist.
make sure it has a globallly unique name.

I already checked that before, but it doesn't seem to be the problem...
Thanks for your help anyway Smiley

Another suggestion?
Logged

Anaël
ben-fr34
New User
*
Offline Offline

Posts: 44


View Profile
« Reply #3 on: November 26, 2007, 01:22:50 pm »

I have same proble with it :
If i put a XML structure in a hidden widget, i can't get the value.
Logged
Lars Knickrehm
eyeOS Team
Hero User
*****
Offline Offline

Posts: 2520



View Profile WWW
« Reply #4 on: November 26, 2007, 06:19:17 pm »

I think the problem with the xml structure is because we're using UTF-8 and so there problems with < and > ...

Use htmlentities($myvarFORhidden, ENT_QUOTES,'UTF-8'); for creating the HTML code and use html_entity_decode($myvarFROMhidden, ENT_QUOTES,'UTF-8'); for creatting the default sting.

That should work, or?
« Last Edit: November 26, 2007, 06:21:52 pm by lars-sh » Logged

Regards, Lars Knickrehm

The eyeOS project 2009. http://eyeos.org/
Websites | Translations | Development
ben-fr34
New User
*
Offline Offline

Posts: 44


View Profile
« Reply #5 on: November 26, 2007, 08:57:21 pm »

It was a part of my problem.

for inject array into a hidden widget, I've unse this function :
function array2HiddenText($array){

   //transform array to XML.
   $sTbl = getArrayText($array,-1,1);

   $sTbl = str_replace("\t", '', $sTbl);
   $sTbl = str_replace("\n", '', $sTbl);

   return htmlentities($sTbl, ENT_QUOTES);
}

If I use hidden widget with "htmlentities" in UFT-8, i have a proble with other caracters (as é, à, ç, è...)... Sorry, I'm french...
Logged
Lars Knickrehm
eyeOS Team
Hero User
*****
Offline Offline

Posts: 2520



View Profile WWW
« Reply #6 on: November 26, 2007, 10:43:18 pm »

I know (German: äöüß Wink ), but that should work! You need to use 'UTF-8' for the third parameter for htmlentinities! So your code should be like this:

Code:
function array2HiddenText($array){

   //transform array to XML.
   $sTbl = getArrayText($array,-1,1);

   $sTbl = str_replace("\t", '', $sTbl);
   $sTbl = str_replace("\n", '', $sTbl);

   return htmlentities($sTbl, ENT_QUOTES,'UTF-8');
}

Does it work? It should work!
Logged

Regards, Lars Knickrehm

The eyeOS project 2009. http://eyeos.org/
Websites | Translations | Development
Nanawel
eyeOS Team
Senior User
*****
Offline Offline

Posts: 389



View Profile WWW
« Reply #7 on: November 27, 2007, 10:16:32 am »

Personally I'm not using special characters (because my array only holds md5 sums, so digits and ASCII letters).
But nom it makes me think about a problem Jose solved a few days back when I told him about my problems with getXmlConfig(). It could come from a cache problem. I'm not sure about that but I'll try to search in this direction.
Logged

Anaël
ben-fr34
New User
*
Offline Offline

Posts: 44


View Profile
« Reply #8 on: November 27, 2007, 11:35:25 am »

It doesn't work with 'UTF-8' : this codage generate other special caracters incompatible with the hidden widget.

it be sure, if you have '<' ou '>' un your text, the hidden widget is not usable.
Logged
Nanawel
eyeOS Team
Senior User
*****
Offline Offline

Posts: 389



View Profile WWW
« Reply #9 on: November 27, 2007, 12:00:05 pm »

What follows doesn't concern the Hidden widget but it may be applied to any encoding problem experienced with widgets.

In eyeFTP, I was forced to use this to prevent "undefined entity" in Firefox:
Code:
eyeX('rawjs',array('js' => 'document.getElementById("'.$myPid.'_eyeFTP_path_TXTBOX").value=Base64.decode("'.base64_encode($dir).'");'));

The element "eyeFTP_path_TXTBOX" is a basic textbox widget, but if I used "setText()" some characters seem to cause an error in the browser. So I replaced the line
Code:
$GLOBALS['eyeFTP_path_TXTBOX']->setText($dir);
by the previous one and.... it works.
Maybe it could help you but I'm not sure.

I forgot to mention it as a potential bug. I'll do it soon.
« Last Edit: November 27, 2007, 09:39:21 pm by Nanawel » Logged

Anaël
Lars Knickrehm
eyeOS Team
Hero User
*****
Offline Offline

Posts: 2520



View Profile WWW
« Reply #10 on: November 27, 2007, 02:53:49 pm »

Maybe the hidden widget should en/decode the text by its own..., or?
Logged

Regards, Lars Knickrehm

The eyeOS project 2009. http://eyeos.org/
Websites | Translations | Development
Pages: [1]   Go Up
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!