this.href will give you the href value; I assume what Musachy posted
will give you the OGNL evaluated value. Why can't you use that?
L.
akshi gupta wrote:
I want to write my custom tag because my aim is to get the href value
for the authorisation so that I can able to render the link according to
the conditions.
Thats why I am writing my own custom tag by extending struts anchor tag
class.
Now can you suggest me how I will get href value in my own custom tag by
extending struts anchor tag.
Thanks,
Akshi Gupta.
Laurie Harper wrote:
As far as I can see, most of that code is redundant; removing all the
noise, this would be completely equivalent:
package com.axis.tag;
import java.util.Properties;
import com.axis.utils.PropertyLoader;
public class MyAnchorTag extends AnchorTag {
@Override
public int doStartTag() throws JspException {
Properties props =
PropertyLoader.loadPropertiesBundle("resources/permissionParameter");
String permission = props.getProperty("permission");
System.out.println(" Method :" + permission);
if(permission == null){
return super.doStartTag();
}
return SKIP_BODY;
}
}
And that doesn't seem to relate in any way to the question you're
asking. In particular, it doesn't use or access the href attribute in
any way, nor does it attempt to use the method Musachy mentioned.
So, what do you actually want to do, and how is it not working?
L.
akshi gupta wrote:
Hello,
I am unable to use this method in my tag handler can you please help
me .. Following is my tag handler code :
package com.axis.tag;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ui.AnchorTag;
import com.axis.utils.PropertyLoader;
import com.opensymphony.xwork2.util.ValueStack;
public class MyAnchorTag extends AnchorTag {
/**
*
*/
private static final long serialVersionUID = 1L;
private PageContext pageContext;
private Tag parent;
protected String preInvokeJS;
protected String targets;
protected ValueStack stack ;
public HttpServletRequest req;
public HttpServletResponse res;
@Override
public void doInitBody() throws JspException {
super.doInitBody();
}
@Override
public void setBodyContent(BodyContent arg0) {
super.setBodyContent(arg0);
}
@Override
public int doAfterBody() throws JspException {
return super.doAfterBody();
}
@Override
public int doStartTag() throws JspException {
Properties props =
PropertyLoader.loadPropertiesBundle("resources/permissionParameter");
String permission = props.getProperty("permission");
System.out.println(" Method :" + permission);
if(permission == null){
return super.doStartTag();
}
return SKIP_BODY;
}
@Override
public int doEndTag() throws JspException {
return EVAL_BODY_INCLUDE;
}
@Override
public Tag getParent() {
return super.getParent();
}
@Override
public Component getComponent() {
// TODO Auto-generated method stub
return super.getComponent();
}
@Override
public void release() {
super.release();
}
@Override
public void setPageContext(PageContext pageContext) {
this.pageContext = pageContext;
super.setPageContext(pageContext);
}
@Override
public void setParent(Tag parent) {
this.parent = parent;
super.setParent(parent);
}
@Override
public Component getBean(ValueStack stack, HttpServletRequest req,
HttpServletResponse res) {
return super.getBean(stack, req, res);
}
@Override
protected void populateParams() {
// TODO Auto-generated method stub
super.populateParams();
}
}
Thanks,
Akshi
Musachy Barroso wrote:
In org.apache.struts2.components.Achor
public void evaluateExtraParams() {
super.evaluateExtraParams();
if (href != null)
addParameter("href",
ensureAttributeSafelyNotEscaped(findString(href)));
}
On Fri, May 9, 2008 at 9:59 AM, akshi gupta <[EMAIL PROTECTED]> wrote:
Actually I am writing my own custom tag by extending AnchorTag
class because
I want "href" value for some business rules thats why I wanthref
evaluated
value.
Now can you tell me from which method href evaluated value is coming?
Thanks,
Akshi
Musachy Barroso wrote:
I am not really sure why you want to know but here is the short
explanation:
<s:url id="edit" action="edit" method="input" namespace="/">
This will construct a url like: "/edit.action", and push it into the
stack, associated with the key "edit" (from the "id" attribute).
Later
on
<s:a href="%{edit}" >Edit</s:a>
"%{edit}" will be evaluated against the stack and "/edit.action" will
be found, so that is the value that the anchor tag will use on its
href.
musachy
On Fri, May 9, 2008 at 8:59 AM, akshi gupta <[EMAIL PROTECTED]>
wrote:
Hello,
If we use anchor tag like this :
(ListSuccess.jsp) : ========> <%@ taglib prefix="s"
uri="/struts-tags"%>
.............................
.............................
========> <s:url id="edit" action="edit" method="input"
namespace="/"
/>
========> <s:a href="%{edit}" >Edit</s:a>
Now , how href value get parse and get the complete url ?
Exactly through which method of the AnchorTag.java?
Can anyone please help me out ?
Thanks,
Akshi
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]