Ash Acharya

Greenhorn
+ Follow
since Jan 09, 2009
Merit badge: grant badges
For More
India
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ash Acharya

Please look at the following code:
class Animal{
public void eat() throws Exception{
System.out.println("Here\'s the exception!");
}
}

class Dog extends Animal{
public void eat(){}

public static void main(String args[]){
Animal a=new Dog();
Dog d=new Dog();
d.eat();
a.eat();

}
}


when i compile this, i get an unreported exception.. why's that so>? I know overriding in java allows the overridden method in a subclass to either not declare any of the overriding method's exceptions or declare only a subtype of the declared exceptions and not declare new or broader unchecked exceptions. why's this behavior coming up? Please explain. Thanks in advance.
14 years ago

Ash Acharya wrote:

Ash Acharya wrote:Dear all,
I have a requirement where in I generate some random words in a method, and return them. in the calling function, I need to check if these words are indeed valid words of the english dictionary. How do I accomplish this in Java? Any pointers would be highly helpful.



Basically I do not want to be implementing it. I'm looking for a Dictionary class which has a list of methods to operate on a dictionary. I want to be passing words to the method, which would return a true/false indicating whether a specific word is valid or not.



If someone can help me find downloadable class and jar files pertaining to the dictionary implementation, that would also be very helpful.
thanks in advance.
15 years ago

Ash Acharya wrote:Dear all,
I have a requirement where in I generate some random words in a method, and return them. in the calling function, I need to check if these words are indeed valid words of the english dictionary. How do I accomplish this in Java? Any pointers would be highly helpful.



Basically I do not want to be implementing it. I'm looking for a Dictionary class which has a list of methods to operate on a dictionary. I want to be passing words to the method, which would return a true/false indicating whether a specific word is valid or not.
15 years ago
Dear all,
I have a requirement where in I generate some random words in a method, and return them. in the calling function, I need to check if these words are indeed valid words of the english dictionary. How do I accomplish this in Java? Any pointers would be highly helpful.
15 years ago
Hi,
I have a jsp wherein I have a select box, which gets populated from the database on form load. How do I get the selected value in the drop down when i visit the same page again?what I exactly mean is that i want to retain the previously selected value in the select box the next time i revisit the same page. I'm able to populate the other text fields on the form with the values they originally had, when i revisit the page. How can I achieve this?
15 years ago
Hi,
This sounds quite weird, but I'm having a problem with using HTML frames with JBoss. when I run the HTML files standalone, they work. But, when I run them through JBoss in eclipse, It says the requested resource is not found. I'm direly in need of help. I dont thoink I'm missing out some configuration info. Any pointers on this would be highly helpful.
Thanks in advance.
15 years ago
Hi,
I'm developing an application in Struts where I'm displaying data from a table in the database inside the <table> tag in my jsp. I also am displaying a checkbox prefixed to each row in the jsp, so that a user would check a checkbox, upon which the checked row would become editable, and then edit the data in the table. On clicking the 'Save' button, the data would be captured and populated as a list of Value Objects. I'm displaying data from the database in <logic:iterate> in my jsp. I'm able to determine which row was checked in my action form, my problem is how would I determine which row(s) were checked in the action class and how would I access the data in those rows in the Action class? I'm keenly awaiting help on this.
Thanks in advance.

15 years ago
Hi,
In reference to the code above, I've another situation where I have to access data in one form bean in another form bean. Currently, I'm able to access the HobbyMap which is in one form bean in the other form bean, but I'm not able to get to its selected value. Here's my code in the other form bean, which I use to access the data in the first form bean:

Second formBean:
-----------------
System.out.println(LoginForm.getHobbyMap.get(LoginForm.getHobbyMap.getHobbyKey());

Any help regarding this please? Thanks in advance.

regards,
Ash.
15 years ago
yeah! got it! thanks a lot Merrill!
15 years ago
Thank you Merrill.. I got the drop down working, but the selection it returns in the success page is wrong, and the corresponding value it returns is also wrong. Any suggestions on where I'm going wrong? Here's the code in my success.jsp.

<p>Your selection is:<bean:write name="LoginForm" property="hobby" /></p> ---- This prints the value associated with my
display text in the drop down.
<p>The value of your selection is:<bean:write name="LoginForm" property="key" /></p> --- This prints nothing!

15 years ago
Hi all,
I'm developing an application in Struts, where I need to have drop downs in my jsp. I'm using treemap in my form bean's reset() to populate the drop down in the jsp. the problem is, how can I get to the individual values in the drop down? here's my code..

jsp:
-----
<tr>
<td>Select your hobby:</td>
<td>
<html:select property="hobby">
<html:options property="keySetHobby" labelProperty="hobbyList"></html:options>
</html:select>
</td>
</tr>

form:
--------
public class LoginForm extends org.apache.struts.action.ActionForm {

private String hobby;
private Collection hobbyList;
private Set keySetHobby;
private String key;
private Map hobbyMap;

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public Map getHobbyMap() {
return hobbyMap;
}

public void setHobbyMap(Map hobbyMap) {
this.hobbyMap = hobbyMap;
}

public Set getKeySetHobby() {
return keySetHobby;
}

public void setKeySetHobby(Set keySetHobby) {
this.keySetHobby = keySetHobby;
}

public String getHobby() {
return hobby;
}

public void setHobby(String hobby) {
this.hobby = hobby;
}

public Collection getHobbyList() {
return hobbyList;
}

public void setHobbyList(Collection hobbyList) {
this.hobbyList = hobbyList;
}

public LoginForm() {
super();
// TODO Auto-generated constructor stub
}

@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
super.reset(mapping, request);

Map<String,String> hobbyTempMap=new TreeMap<String,String>();

hobbyTempMap.put("-1","Select");
hobbyTempMap.put("0","Eating");
hobbyTempMap.put("1","Sleeping");
hobbyTempMap.put("2","Drinking");
this.setHobbyMap(hobbyTempMap);
this.setHobbyList(hobbyTempMap.values());
Set keys=hobbyTempMap.keySet();
this.keySetHobby=keys;
}

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

if (this.getHobby().equals("Select"))
errors.add("keySetHobby", new ActionMessage("error.KeySetHobby.required"));
return errors;
}
}

I'm keenly looking forward for help.

regards,
Ash.
15 years ago