kanishk dewan

Greenhorn
+ Follow
since Aug 11, 2011
Merit badge: grant badges
For More
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 kanishk dewan

Hi,

I am trying to have a java-script function executed when the value of a Dojo auto-completer is changed by the user.

But when I use the usual onChange event handler in the dojo auto-completer for executing java-scripts, it has no effect i.e. the java scripts are not called.

I have used the java scripts to do the following 2 things :

1) Call a struts 2 action (by notifying a topic and then listening it elsewhere).

2) Change the value of a hidden field (to pass on some data to the action).

Although for notifying a topic there is another way :
using attribute --> valueNotifyTopic="topicName".
This will publish the topic and I can listen it elsewhere to call an action.
But this method does not allow me to change the value of the hidden field I mentioned.

This is the code:

Here the onchange attribute seems to have no effect.

Please advice.
Thanks!!
12 years ago
Hi Mohana,

Thanks for a quick reply.

I am using ajax with dojo plugin, but how does it enable me to know which element has caused the event action. I need to know this in my action class.

Thanks
Kanishk
12 years ago
Hi All,

I have 5 drop downs on a jsp. I have a single action which dynamically changes the contents of the drop downs depending on selection change in one of the drop downs.

The problem is, I want to determine which of the five drop down was changed. I need this info in the action file.

Please advice how to do this.

I dont think I need to provide any existing code for this.
And if I am missing any info please tell.


Thanks
Kanishk
12 years ago
Hi Aatka Ali,

This thread is not related to your problem. What you need is an Autocompleter (a dojo component) which allows user to see the drop down contents change as he/she types in the textbox. Google it you should find lots of help.

Also I think you should use Struts framework, unless there is some technological constraint. Try it. Its not very difficult.

Regards
Kanishk
12 years ago
Hi Vijay,

Now I am facing the looping problem.
As you said I tried modifying so that the action does not forward to the jsp page.
I tried removing the result tag in the action tag in struts config file, so that the action does not forward to the page.
But doing so causes the drop downs not to be populated.
Was there some other method you were referring to for not allowing page forwards?

Waiting for your reply.

Thanks!!
12 years ago
Hi all,

Despite so many topics on this one I have not been able to figure it out for struts 2.

I have 5 drop down lists, and I want that a change in the selection of any one of these, should cause change in the contents of other drop downs without loading the complete page again, i.e asynchronously.

What I am currently trying is (using dojo) :

1.) When the selection of any of drop downs changes, the onChange event publishes a dojo topic.

2.) A topic listener causes an action to be executed.

Up to this point its fine. The action gets executed and sets the lists for the drop downs as expected.

Now what should happen is that :

--> When the action has completely executed it should come back to the same page (set in the struts config file) and update the lists of the drop downs with the new lists set in the action class.

I can not figure out how to do this.

Please help.
Also if there is a better way of doing it please help me out with it, along with the codes please.

Here is the code of what I have done:

The jsp page containing the drop downs.



the struts config file:


The action class just sets the lists for the drop downs. I have checked that it works fine.

Please help asap.

Thanks!!
12 years ago
Hi Vijay,

I have not been able to get around this till now . Waiting for your reply.

Please help asap.

Thanks!!

12 years ago
Hi Vijay,

Thanks for such a quick reply.
I am still not able to work it out even after a lot of tinkering around, taking inputs from your posts.
Here are some findings:


1.) In the following tag

as soon as I change "<sx:a>" to "<sx:div>" I have a strange error:

"Error loading '/getLists.htm' (404 Not Found)"

is displayed on the top of the page, but the page is displayed and functions correctly, i.e. the action is called and executed correctly, except for one thing: the function that was supposed to execute only when the onchange event occurs, also executes when the page loads for the first time, I guess that could be the reason that was causing the looping problem on your page.


2.) The 2nd thing is that, when I use "#application.customerList" instead of simply "customerLists" I get the following server error :

The requested list key '#application.customerList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location].

In this I would like to point out that when (using simply "customerLists") I print the lists in the action class (on the server console) they get printed as:
[contname1, contname2]
[custname1, custname2]

i.e. in the form of values instead of objects. I guess this is fine, but was just giving additional info, in case it means something.


3.) I looked into struts 2 action tag on apache struts 2 documentation site, and I think I found a way. I will see if it works once I get to that stage, i.e. once I encounter the "looping problem".

Because till now all thats happening is that the action gets executed correctly but it doesnt effect the lists of the drop down.


Please advice.

Thanks!!
12 years ago
Hi Vijay,

I know I am raising up this thread again after such a long time, but after hours of search this is where I think I might find my solution. Please excuse me if you find this post lengthy.

I am using the same method as you used for updating drop down lists (struts 2 version). But the problem I face is that although my action class gets executed (I set the lists for the drop downs in action class), the drop downs don't get populated according to the lists set in the action class.

Also I would like to clarify 3 things:

1.) <s:url action="select2" var="url"/>
Here, did you use "select2" in action because your action class name is "select2.java" or because your jsp page name is "select2.jsp" ?

2.) list="#application.countries"
Here, I assume that the list name that you set in the action class was "countries". Then why did you use "#application.countries" instead of simply "countries".

3.) In my case I have 5 drop downs that have to be updated in case any one of then is changed. So the way you have done it, do I have to create a separate jsp for each drop down ?

Here is what I have done, please have a look:

My jsp page:




Here is my struts config (although I dont think there is any issue here):




Please help me in resolving this issue asap. Its really bugging me.

Thanks!!!
12 years ago