[Plone-UI] portlet not updating content.

unconquered_sun rafael.g.p.passos at gmail.com
Sun Sep 23 23:40:09 UTC 2007


Hello, i am new to Plone and i am learning its use for my current work and i
am having trouble with the properties in a page. I am using Plone 2.9, if i
am not mistaking, and have created a html code to calculate a function based
on an input valor and the selection of a function from a drop box. Then i
use a python script to calculate and generate the html code of the line with
will replace another in the orignal page. The page alone appears to work
nicely when i test it using the "test" tab in the plone manage, but when a
use the same code in the right_slot in the properties tab, the resulting
"potlet" on the right side of the site (by the way i am using the default
skin that come with plone, so the new addition is right below the Plone
calendar) don't return the new line, the drop box and everthing else is
there, but the button to calculate the result don't generate the line it
should produce.
The code of the page is below:

<html xmlns:tal="http://xml.zope.org/namespaces/tal"
        xmlns:metal="http://xml.zope.org/namespaces/metal"
        i18n:domain="plone">

<body metal:define-macro="portlet">

<script src="prototype.js"></script>
<script>
          
             function  ajaxConversor(){
                        var sel = $F('selecao');
                        var valor= $F('valorEntrada');
                        var url = 'conversor_python';
                        var pars = 'valor=' + valor + '&tipo=' + sel;
                        var myAjax = new Ajax.Updater(
                                   {success: 'resultado'},
                                   url,
                                   {
                                               method: 'get',
                                               parameters: pars,
                                               onComplete: mostraResposta
                                   });
            }
            function mostraResposta(requisicaoOriginal)
            {
                        //copia a combobox para o span
                $("resultado").innerHTML  = requisicaoOriginal.responseText;

            }

</script>



<div>
<dl class="portlet">
   <dt class="portletHeader">
    <table id="tab" border="0"  align="rigth">

    <tr><td align="center"><input id="valorEntrada" type="text"></td></tr>

    <tr><td align="center">Converter de:</td></tr>
    <tr><td align="center"><select id="selecao">
        <option value ="1">angstron</option>
        <option value ="2">atm</option>
        <option value ="3">Btu(b)</option>
        ...
        <option value ="63">torr</option>
        <option value ="64">TAU/circ mil.ft</option>
    </select></td></tr>

    <tr><td colspan="2" align="center"><input type="submit"
value="Converter" onClick="ajaxConversor()"></td></tr>
    </table>
    </dt>
    </dl>
    <ul class="Pesq">
    
    </ul>
</div>

</body>
</html>

And the python script is here:

request = container.REQUEST
RESPONSE =  request.RESPONSE

###############################
# Recebe os valores da Pagina #
###############################
VALOR = request.get('valor')
TIPO = request.get('tipo')

def pot(x,y):
 return float(x)**float(y)

def angstrom(x):
 print "<p>m: ",float(x)*1.0*pot(10,-10),"</p><br>"
 return printed 

def atm(x):
 print "<p>Pa: ",float(x)*1.0133*pot(10,5),"</p><br>"
 return printed

def Btu(x):
 print "<p>J: ",float(x)*1.054*pot(10,3),"</p><br>"
 return printed

....


############
# Switch Python #
############

x=0
a=[]
if True:
 result = {
   '1': lambda x: angstrom(valor),
   '2': lambda X: atm(valor),
   '3': lambda x: Btu(valor),
   ...
   '62': lambda x: ton(valor),
   '63': lambda x: torr(valor),
   '64': lambda x: TAU_circ_mil_ft(valor)
 }[TIPO](x)
 print "<p class='Pesq'>",result,"</p>"
 return printed
return a


this code works testing the page alone, but not when i put on slots of the
site.
Please, any one help me !!!:-D

-- 
View this message in context: http://www.nabble.com/portlet-not-updating-content.-tf4506170s6746.html#a12851399
Sent from the User Interface & Design mailing list archive at Nabble.com.





More information about the UI mailing list