Wiadomosc od Enrique Perez z 2006-09-06 18:30 brzmiala:

Hi all,

I was trying to see which attributes and properties my portlet views when clicking a button in a form.
So I put this code in the "processAction(req,resp)" method:
--------------------------------------------------------------------------------------
   private String atributos;
   private String propiedades;

public void processAction (ActionRequest request, ActionResponse response)
       throws PortletException, IOException{

String at1 = request.getAttributeNames().nextElement().toString(); atributos = at1 + ": " + request.getAttribute(at1).toString()+"<br>";
           while (request.getAttributeNames().hasMoreElements()){
String at = request.getAttributeNames().nextElement().toString(); atributos = atributos + at + ": " + request.getAttribute(at).toString()+"<br>";
            }

String prop1 = request.getPropertyNames().nextElement().toString(); propiedades = prop1 + ": " + request.getProperty(prop1).toString()+"<br>";
           while (request.getPropertyNames().hasMoreElements()){
String prop = request.getPropertyNames().nextElement().toString(); propiedades = propiedades + prop + ": " + request.getProperty(prop).toString()+"<br>";
            }
   }
-------------------------------------------------------------------------------------- and show the result ("atributos" and "propiedades" strings) when rendering content in doView() method.

But both loops seem to have no end =/
I've tried just with two properties (or attributes); that is to say, removing the loops, and what I guess is that it's always picking the same property (or attribute).

Is that something to do with my code? "nextElement()" is supposed to place the pointer in the next element of the Enumeration object, isn't it?
I've not tested your code, but the following will work:
Enumeration attrNames = request.getAttrubuteNames();
String attrs = "";
String attrName;
while(attrNames.hasMoreElements())
{
        attrName = attrNames.nextElement().toString();
        attrs += attrName + ": '" + request.getAttribute(attrName) + "' ";
}

--
pozdrawiam,
    Jacek Wislicki

[EMAIL PROTECTED]
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to