Ajit Amitav Das

Ranch Hand
+ Follow
since Dec 14, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Ajit Amitav Das

You can do this as follows :

<s:select list="testArray" listValue="filterArray(getTestArray()[index])" />

where your model should contain corresponding method for data acess:

public String[] getTestArray(){
//Add your array here I have used string for simplification you can use any object
return new String[]{"item1test","item2test"};
}

public String filterArray(String str){
//Do alll the customization for display here
return "added : "+str;
}
public int getIndex(){
//Return the index here, it's upto you how to return the selected index
//U can do it by setting into a hidden field on onChange event of the select
//and then access that property here.
// I have just hardcode here for demonstration
return 0;
}

You will get HTML as follows :

select name="" id="testSelect">
<option value="item1test">added : item1test</option>
<option value="item2test">added : item1test</option>
</select>

Hope this will help you in addition to what you tried before.
8 years ago
Struts2 uses FTL (freemarker template) internally to render components.

In your case for radio buttons it uses "radiomap.ftl" for generating the HTML code.

This file will be present in struts default jar file, extract this file and modify accordingly as per your customization put a break tag after each iteration of the collection items.

Create a folder named as theme under your webapp project and create a folder named as XYZ(example : radiovertical) under that theme folder and put your modifed radiomap.ftl file under XYZ folder.

radiomap.ftl is a big file to mention so just putting code snippet how to do this: modifed code are mentioned in bold font.

<@s.iterator value="parameters.list">
<#if parameters.listKey??>
<#assign itemKey = stack.findValue(parameters.listKey)/>

// rest of the code which I have deleted for wrapping it in a small conversation.

<label for="${parameters.id?html}${itemKeyStr?html}"><#rt/>
${itemValue}<#t/>
</label>
<br /><br />
</@s.iterator>


After all these changes use your theme (XYZ ) for struts radio tag as follows:

<s:radio theme="radioVertical" .....rest of the things here />

This will create each item in a new line.

Hope this will give you some valid information and technique to use/customize struts tag.
8 years ago
Hi All,

I am facing the following problem when trying to use TransformerFactory.newTemplates(). Please find below the issue description:

Line 1.TransformerFactory factory = TransformerFactory.newInstance();
Line 2.Source strSource = new StreamSource(file);
Line 3.Templates templates = factory.newTemplates(strSource);

At line 3, I am getting templates as null. Also in the console of my Eclipse, I am getting the following error:

Fatal Error abc.xsl:4:33: The prefix "xsl" for element "xsl:template" is not bound.

file:///F:/workspace/PDFKARA/VSPDF/bin/abc.xsl; Line #4; Column #33; org.xml.sax.SAXParseException: The prefix "xsl" for element "xsl:template" is not bound.

Note: I have the following jar files in my lib folder related to XML:

a.)xalan 2.4.1.jar

b.)xml-apis.jar

c.)xercesImpl-2.2.1.jar

Please could you help?

Hi All,

I am using the ajax framework prototype.js and calling the struts 2 action class from the javascript.I have a condition in my struts 2 action class and if that condition is satisfied i need to redirect from the current action class to a different action class without sending a response to the javascript method which made the ajax call.
But my issue is when i redirect to a different action class and from there when i try to send the result to a JSP page, i am not able to display that JSP page.The browser is not displaying the other JSP and instead remains in the same JSP page which made the ajax call.

Please let me know how to solve this problem.

8 years ago
Hi
Namit , don't loose your heart , you are the best to know your state of mind and heart now , my advise will be take 2 or 3 days sit and analyse wheather the effort you had given was sufficient or it needs more and the areas of your weakness , be specific about objectives , do small small programs related to the objectives and try to crack the concepts and logic behind it , before registering exam again you first take some mock test and if you are scoring constantly 80 percent or more than that then register for exam and schedule the exam within 10 days of registration .Be confident and sure that you have covered almost all objectives you will see result has to come good .

All my best wishes are with you. Best of luck. Cheer up.
11 years ago
Hi
Ranchers,
I have one doubt while reading HFServlet&Jsp on question in page no 356.
the question goeslike this

<jsp:useBean id="person" type="foo.Employee">
<jsp:setProperty name="person" property="name" value="Fred">
</jsp:useBean>
Name is :<jsp:getProperty name="person" property="name"/>

and the servlet code are ...

option 1:
foo.Person p=new foo.Employee();
p.setName("Evan");
request.setAttribute("person",p);

option 2:
foo.Person p=new foo.Person();
p.setName("Evan");
request.setAttribute("person",p);

option 3:
foo.Employee p=new foo.Employee();
p.setName("Evan");
request.setAttribute("person",p);

where Person is an abstract class with seter and geter of property "name" and Employee is a concrete subclass of Person having setter and getter for property "empID" and both are in package "foo".

For me option 1 and 2 is correct as in
option-1 we are setting attribute in request scope but in jsp page we are not specifying any scope so by default it will serch in "page" scope and it won't find it and on request it will fail.
option-2 is also corrext as we are tying to cereate one instance of abstract class.
but my doubt is in option-3 , in this case also we are setting attribute in request scope and trying to find it in page scope in jsp page which should give same error as in option-1 but the anser is given that it is correct and it will print the name.
how it is happening ? will anyone help me out .
Thanks Berts
Thank you so much for putting me here today .
Now which exam i should go for "Developer Exam " or "Web component Developer Exam" or should i go both at same time .
11 years ago
congrats man , great job.
11 years ago
Hiiiii Ranchers , i passed SCJP 1.5 exam with 94% on saturday, it was really a nice experience for preparing such a good exam , first i would like to thank k&B for their such a nice book , i read it 3.5 times before giving exam , i byhearted all concepts of this book by reading again , again and again , and with with a lots of small small programs ,i also like to thank Bruce Eckel for his great book (Thinking in java)which i follwed in cource of my preparation ,also want to thank marcus green for his mock exams and all of here for helping me clearing my doubts , really i had never expected for scoring so much ,i had expected anythng around 75% as i was scoring that much in final master exam by k&B , but i did it finely in exam , i would like to share my experience with others .It was really really nice experience and my suggests to others will be always think logically because in jave for everything there is one logic behind it and try to crack concepts by doing small small programs , never read a java book like novel and always try to answer mock exams by your own without watching answer first and then judge from where you can start again and be focoused on sun's exam objectives and watch "exam watch" and "Two minutes Drill" in K&B book in last moments of before going to exam. I would also like to get suggetion on which exam i would concentrate on now? Thanks Thanks you all once again
11 years ago
Hi Ranchers,
I am in my final week of preparation for scjp , previously i was preparing for scjp 1.4 but later on i changed my mind and registered for 1.5 ,though i have read new stuffs in 1.5 ,am not confident about generics till now and my exam is on next week so am little bit tensed now , how many number of questions i can expect in newer version of exam on generics and related on those stuffs ,and what is the difficulty level of questions in real exam ? am preparing from k&B book , are the questions given there are equivalent to those real exam or real exam questions are more difficult .

And atlast i need some some advice how to appear questions on exam and how to manage time.
Hey guys ,
can anyone give any information about discount voucher in bangalore and till what date we will be able to purchage that voucher , if possible can anyone give some contact number/address of those organizatons.I was planning to purchage it after 1 week , but as i got information that it is valid till 15th sept in hyderabad , i thik i should purchage it quickly to have that offer.
means object will be garbage collected or it's won't be allowed to be garbage collected.
Hi Ranchers one more doubt i have on garbage collection. and question goes like this.
Question :
If a Runtime Exception is thrown in the finalize method -

1.The running application crashes.
2.The exception is simply ignored and the object is garbage collected.
3.The exception is simply ignored, but the object is not garbage collected.
4.The Exception causes the JVM to crash.

What will be the answer wheather it will be option-3 or option-4 ?