Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
Parameters - What they are and how can they be used? 
Before posting this question I did search in all blogs to see if anyone explained the usage of the Parameters.
 
For example, on the All Properties of the Event Handlers, there is a section "Data" underwhich we can add multiple Parameters. Where can we access these parameters?
 
I have an image control that will do a partial refresh (refresh id is the same image id) to run a SSJS. onComplete of the refresh, I need to set the className of this image. I don't have a handle to the image object in the onComplete event. It may be because the onComplete is not an event of the image (like the image's onClick), but it is part of the ajax call.
 
Is there a possibility here to use the event parameters to pass the image id or the image object? 
 
Thanks, 
Rajeev Menon. 
 
 
 
Domino Development / XPages
Tagged
Rajeev Menon - about 1 year ago |  |  | Viewed 140 times
File Name
Parameters.jpg

There are 4 answers

0votes
The parameters you are discussing are not used in the way you are asking.
 
I am not sure what you are specifically looking to do,  I'm not sure what you are trying to set when you say "className" ... if you mean the styleClass, then there are two ways you can do this.
 
First, if you are partial refreshing the image, you can make all or part of the styleClass computed. For Example:

Completely computed can be like this:

<xp:img styleClass="#{javascript: -Your Script Goes Here- }">
 
That will allow you to compute the class server side based on whatever you want ...
 
If you want to specifically set it client-side instead of computing it, you can do it like this by adding the following in your xp:eventhandler:
 
<this.onComplete>
   dojo.addClass(dojo.byId('#{id:ServerSideIDofImage}'), 'YourCSSClassHere');
</this.onComplete>
 
Let me know if I missed what you were looking to do...


Jeremy Hodge - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


1votes

Hi Jeremy,

 

Let me give you a little more details to it.

 

I am displaying notes documents as a table using the repeat control. The first column of each row is an Image control. On clicking the image icon, it saves the UNID of the document on the user profile. At a time only one document unid should be allowed to add to the user profile.

 

Here is what I am doing. 

 

The image control's styleClass is already computed using SSJS (it checks, if that row's unid is what is saved on the user profile, if yes, show iconSet, else show iconNotSet). The image controls are set to partial refresh itself. On partial refresh, it does the saving of the unid on the user profile. onComplete of the event, I use dojo to change all image control's className to iconNotSet. And then I need to set the className of the clicked image to iconSet

 

Here I don't have the current image object or it's id on the onComplete event. I know one way to get the images id. (Use arguments[1].url gives the full partial refresh url which also has the image's id as the query string. Actually the URL is in the format . .xsp?xxxxx$$ajaxid=<imageid>)

 

What I really want to know is, what are those event parameters for? Can you give an example where those could be used? Also, if you know of a way to pass the image object to the onComplete event that will also help.

 

Thanks,

Rajeev Menon.



Rajeev Menon - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


1votes
Marked as correct on6/1/10 10:04 PM
The Parameters are used when your context is a component in a composite application, which allows you to pass parameters to the component. It is used exclusively in that context, and is not available otherwise (and is never available client side).
 
You can use the following line of code to see what the last ID submitted to the server is (which in your onComplete, should be the image you just clicked)

dojo.query('[name="$$xspsubmitid"]')[0].value
 
That locates the $$xspsubmitid field and retrieves its value.  On a partial refresh, the client side XSP object sets the value of this field to the ID of the object receiving the refresh, in this case, your image.
 
However, it appears to me from your description this is unnecessary, if your image class is computed server side, and the image is the target of the partial refresh, then the refresh should change the class of your image, however, you are then resetting it in the onComplete when you say:
 
"onComplete of the event, I use dojo to change all image control's className to iconNotSet."
 
Would it not be better to use dojo to change all image controls to iconNotSet during the partial refresh's onStart event, and then just let the partial refresh handle recomputing the class for the single image that was clicked, since only one image can be selected at a time anyway.
 
Also, I am curious, are you using a true profile document?  I am curious why ... Does the data need to remain persistent after the users session is over? Or is it strictly for settings during the session, and if so, wouldn't sessionScope.get/put be more appropriate? If it does need to be persistent, then I would look at the use of applicationScope, unless you need that information to be available to other users outside of the XPages and/or the JVM...


Jeremy Hodge - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
"The Parameters are used when your context is a component in a composite application, which allows you to pass parameters to the component. It is used exclusively in that context, and is not available otherwise (and is never available client side)."
 
That was the answer that I was looking for while posting this question. Thanks Jeremy.
 
I also thought of setting the styleClass on "onStart", the reason why I had doubts about this approach was because of the frequent "time out" errors experienced with the partial refreshes. That's why I wanted to do everything on successful completion of the partial refresh. Anyways, I learnt that I can increase the submit latency with increasing the submitLatency value.
 
Regarding your question about the Profile: It is just a normal notes document.
 
Thanks again, 
Rajeev Menon. 


Rajeev Menon - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community