Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts Struts2 ComponentTagSupport
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


madhuri
Struts2 ComponentTagSupport
1 Answer(s)      4 years and 10 months ago
Posted in : Struts


I am working on struts2 custom tags using ComponentTagSupport.

I am referring to this link
http://joshuajava.wordpress.com/2008/12/27/creating-custom-components-with-struts-2/

I made example working. but my requirement is with the help of my custom tag i have to display the body if the name attribute is present how do i do that?



public class HasPermissionTag extends ComponentTagSupport {

/**
*
*/
private static final long serialVersionUID = 1L;
String name;

public void setName(String name){
this.name=name;
}

@Override
public Component getBean(ValueStack stack,
HttpServletRequest request,
HttpServletResponse response) {
return new HasPermission(stack);
}

public int doStartTag() throws JspException {

int returnInt = SKIP_BODY;

try {

component = getBean(getStack(), (HttpServletRequest) pageContext.getRequest(),
(HttpServletResponse)pageContext.getResponse());

populateParams();
String permName=name;
if (permName){
returnInt = component.usesBody() ? EVAL_BODY_BUFFERED : EVAL_BODY_INCLUDE;
System.out.println("body");

} else {
returnInt = SKIP_BODY;
System.out.println("no body");

}

} catch (Exception ioe) {
ioe.printStackTrace();
throw new JspException("Error:" + ioe.getMessage());
}

return returnInt;
}


protected void populateParams() {
super.populateParams();

HasPermission hello = (HasPermission)component;
hello.setName(name);
}

}

and my Component is

public class HasPermission extends Component {

String name;

public void setName(String name){
this.name=name;
}

public HasPermission(ValueStack stack) {
super(stack);
}

public boolean start(Writer writer) {
return true;
}

public boolean end(Writer writer) {
return true;
}

@Override
public boolean usesBody() {
return false;
}


}


but i am getting infinite loop. i dont know bout ComponentTagSupport much Pease any body help me.

Advertisement
View Answers

February 4, 2010 at 4:35 PM


Hi Friend,

Please visit the following link:

http://www.roseindia.net/struts/struts2/index.shtml

Here you will get lot examples.

Hope that it will be helpful for you.
Thanks


Related Tutorials/Questions & Answers:
Struts2 ComponentTagSupport - Struts
Struts2 ComponentTagSupport   I am working on struts2 custom tags using ComponentTagSupport. I am referring to this link http... HasPermissionTag extends ComponentTagSupport { /** * */ private
struts2
struts2  sir.... i am doing one struts2 application and i have to make pagination in struts2....how can i do
Advertisements
struts2
struts2  dear deepak sir plz give the struts 2 examples using applicationresources.properties file
struts2
struts2  hi all i am going to run struts2.x program i got this error when server started java.lang.RuntimeException...: Struts2 Tutorials
Struts2
Struts2  i want select multiple items from select list in struts2.when i did like that the two selected values must saved into databse in two diffirent rows.pls provide any one code for this i am new to Struts2
struts2
struts2   Sir when i have run my struts 2 web application,every time i get error " request resources is not available",,,what is this,,,plz help me
Struts2
Struts2  Hi, I need a solution for displaying success message in same page in struts2. how to redirect same page in struts2.Please help me.   hi friend, To know how redirect action can be done in struts 2 you can go
Struts2
Struts2  Hi I am using struts 2,In struts2 architecture ,I couldn't understand the purpose of ActionMapper and ActionProxy.My Question is,when the request comes into the picture,the filterdispatcher consult the ActionMapper
Struts2
Struts2  java.lang.NullPointerException org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69... exception while submitting the update form in struts2 I am using tomcat6.0 ... its
struts2
struts2  how to read properties file in jsp of struts2   Hi, You can use the Properties class of Java in your action class. Properties pro = new Properties(); FileInputStream in = new FileInputStream(f); pro.load
STRUTS2
STRUTS2  sir but my question is using ApplicationResources.properties in STRUTS 2.i cant get the values into my application.but in the exmple given at roseindia,u cant use the properties file.i use actionclass-validation.xml
struts2 - Struts
Struts2 and Ajax Example  how to use struts2 and ajax
Struts2 and Hibernate
Struts2 and Hibernate  how to fetch database value from one page to another page in struts2 and hibernate
struts2 - Struts
struts2  how to pre populate the fields using struts2 from the database
Struts2 tag
Struts2 tag  function of hidden tag?   Hi Friend, <s:hidden> tag create a hidden value field.It means it stores the value but cannot be visible. For more information, visit the following link: Struts2 Tutorial
struts2 - Framework
struts2   RoseIndia i m using this code for a bean in struts2.but geting error SEVERE: Could not instantiate bean how to resolve this.thnx
Struts2 and Hibernate
Struts2 and Hibernate  Sir/ madam, Can we use iterator tag in struts for fetch the database value and shown on form. if yes then how
New to struts2
New to struts2   Please let me know the link where to start for struts 2 beginners   Struts 2 Tutorials
struts2 - Framework
struts2  Hello, I am sathish.. I got problem in stuts2 ? Do tomcat5.5 support struts2 ? Now , currently my application running on tomcat 6... and mainly i want support with tiles(struts 2)...now which struts2 jars i have to use
struts2 - Framework
struts2  Hello, I am sathish i got one problem with struts2 framework...i want to create a jsp page in struts2 i need two buttons in tha jsp ..but these buttons are not dispaly in same row.....once if i create two buttons
Help in Struts2
Help in Struts2  Hi, in struts 2 how to get the values from db and show in jsp page using display tag or iterator tag thanks in advance
themes in struts2
themes in struts2  i want to create themes in strut2 can any one tell the step by step procedure of how to create it.with example links thanks in advance
Struts2 - Struts
Struts2  Hi, I am using doubleselect tag in struts2.roseindia is giving example of it with hardcoded values,i want to use it with dynamic values. Please give a example of it. Thanks
Struts2 Internationalization
Struts2 Internationalization  Hi How to use i18n functionality for indian languages in struts2 ? I am able to use french and english but none of the Indian languages. Pls help. Regards Vaishnavi   Please visit
struts2 Autocompleter
struts2 Autocompleter  hi. I am working Auto Completer Example in rose india.net http://www.roseindia.net/struts/struts2/struts2uitags/autocompleter... conflict. Thanks    Hi sir i am using struts2 2.1.8.1 Thanks venu
struts2 filters
struts2 filters  hi i created a filter,if the session is null then it should to go error page that ur not authorized to access, nw my question is how to use means how to call filter to do the task pls help me
Struts2 and Hibernate
Struts2 and Hibernate   I have a simple application in Struts2 and Hibernate which have simple form for entering contact information and after submitting the page it saved to the database. This was a tutorial i was trying from
Struts2 and Hibernate
Struts2 and Hibernate   I have a simple application in Struts2 and Hibernate which have simple form for entering contact information and after submitting the page it saved to the database. This was a tutorial i was trying from
struts2 select tag multiple
struts2 select tag multiple  struts2 select tag multiple
Struts2 and Hibernate
Struts2 and Hibernate  Hello Sir, I am trying to fetch database value from one page to another page. Means i am submiting the form value... using struts2 and hibernate3.0. I need ur help try to short out this asap
struts2 tiles.xml
struts2 tiles.xml  Hi, I want to use .properties file data in tiles.xml file of struts2(2.1.8) application to display title. sample code I have used: In tiles.xml: <definition name="disastersettingsview_users" extends
Advertisements
 

 

 

DMCA.com