Thank you Dave, I just managed to resolve the issue in a slightly
earlier post.

Here is the action that backs the JSP. Now In my table I have a column
which prints out db.localhost.test.Groups[name=ADMIN] because the object
is db.localhost.test.Groups and it has a single property called name.
Another thing to fix.


package struts2.reflection;

import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import org.apache.commons.collections.BeanMap;

/**
 *
 * @author ken
 */
public class GetPropertyNames extends ActionSupport {

    List result = null;
    BeanMap propertyValues = null;

    private EntityManagerFactory entityManagerFactory;

    public void setEntityManagerFactory(EntityManagerFactory
entityManagerFactory) {
        this.entityManagerFactory = entityManagerFactory;
    }

    @Override
    public String execute() {
        EntityManager entityManager =
entityManagerFactory.createEntityManager();
        Query namedQuery =
entityManager.createNamedQuery("Customers.findAll");
        result = namedQuery.getResultList();
        if (result != null && result.size() > 0){
            propertyValues = new BeanMap( result.get(1) );
            //has unwanted property "class" but there is no valid remove
method that will not throw an exception, so will take care of this in
getter
        }
        return SUCCESS;
    }

    public List getResult(){
        return result;
    }

    public List getPropertyValues(){
        //can now remove unwanted property "class"
        ArrayList arrayList = new ArrayList(propertyValues.keySet());
        arrayList.remove("class");
        return arrayList;
    }
}

On Tue, 2011-02-01 at 18:49 -0500, Dave Newton wrote:
> On Tue, 2011-02-01 at 15:35 -0700, Ken McWilliams wrote:
> > <s:iterator value = "resultList">
> >     <s:iterator value="propertyNames">
> > ...
> >
> > I want propertyNames to be evaluated and the result used
> > as the value for the iterator, not simply interpreted as a
> > normal list.
> 
> Evaluated in what context? As a list of named properties on the item
> being iterated over? Are you implementing this in Java, or different
> JVM language?
> 
> I thought I remembered foo[propName] "just working", but I couldn't
> tell you what I was backing the view *or* model with, which could make
> a huge difference :/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to