1

I have this function in Struts 1:

/*
 * (non-Javadoc)
 * 
 * @see org.apache.struts.taglib.bean.WriteTag#doStartTag()
 */
public int doStartTag() throws JspException {

    Carac carac = (Carac) TagUtils.getInstance().lookup(pageContext, name, property, scope);
    // Code here
    return SKIP_BODY;
}

and I am trying to create the same tag in Struts 2 but don't know what's the purpose of this:

TagUtils.getInstance().lookup()
рüффп
  • 5,172
  • 34
  • 67
  • 113
Nabs
  • 31
  • 1
  • 7

2 Answers2

1

I found a solution to get my object from the view to the tag in struts 2 :

my tag :

<%@ taglib uri="wells/taglib/produit" prefix="produit"%>

         <produit:produitPhoto prod="row" />

Here is how t can get it:

  getStack().findValue(this.prod, Produit.class); // return Object Produit

Ref : Class TagUtils

Roman C
  • 49,761
  • 33
  • 66
  • 176
Nabs
  • 31
  • 1
  • 7
0

Precisely what the documentation says: it returns the named bean's property from the provided scope.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • thanks for the response ,but how can i translate it to struts 2. i really didn't get how . – Nabs Dec 27 '12 at 15:17
  • 1
    @Nabs It'd be easiest to start with any of the S2 tags and work from there. They subclass the ContextBeanTag to provide easy access to params and the value stack. You could also consider implementing a JSP-based tag or doing more work outside of the servlet framework. – Dave Newton Dec 27 '12 at 15:22