How to get the NotesUIDocument in java code?

hi,I am the new one for lotus notes. I do some lotusscript in the nsf file, which will call java. When click the send button, I want to change the notesui “EnterSendTo”. so I write some code in the “Querysend”, then call the java code. There are in the java code"NotesUIDocument doc = (new NotesUIWorkspace()).getCurrentDocument();" but I can not get the doc.

How to get the NotesUIDocument? thanks!

zhenyan

Subject: Java or LotusScript??

Your code looks like something in between. BTW, as of 8.5.1, you cannot use Java in form events, nor does the Java API of Notes provide any UI classes.

Subject: in the java code.

I use LS2J. so some code in java. I want change the “sendTo” value in java code. e.g.NotesUIDocument doc = NotesUIWorkspace()).getCurrentDocument();

NotesUIField sendToField=doc.getField(“EnterSendTo”);

sendToField.setText(“my test sendto”);

but some error. like no workspace init. I confuse about that.When I click the send button, then I run the java code above.(I run it from LS2J)

BTW, what do you mean?“you cannot use Java in form events, nor does the Java API of Notes provide any UI classes.” I can not use the ui doc? e.g."NotesUIDocument "?

thanks

Subject: just wondering

Isn’t LS2J object instantiation done by invoking ‘JavaClass.CreateObject()’, not by ‘new …’ as in your code example? (See the LS2J examples in Designer help.) I must admit that I’m not an LS2J expert though.

And yes, the UI classes (NotesUiDocument etc) are currently available in LotusScript (native) only.

Subject: maybe the init order. I am not sure

hi,Jochen Sack

thanks!

I create the new source in the code->script…then I add the LS code in the option

Uselsx “*javacon”

Use “JavaSource”

I can run my java code in the LS code. like that

Set jSession = New JavaSession

Set jSample = jSession.GetClass("tmp008/ClassSample").createObject()

jSample.setStrMyName(" ls ------------")

Msgbox jSample.getStrMyName()

this is my java package and java class name

tmp008/ClassSample

It will run. but if I add some java code which get the uidocment, it does work. the error is no uiworkbench. so I think that maybe the init order.do you think so?

BTY,I can get the uidocment object in java code, when I create a plug-in project.but the project must indepence the “com.ibm.notes.java.ui” jar.

I guest it will be ok.

If you interested in my topic,we can talk it in msn. If you wish, It’s my pleasure. This is my msn:zezhenyan@hotmail.com

Subject: A possible approach…

Ze,

As mentioned previously, the Notes UI classes are generally not available to Java. With Notes 8.5, a few Notes UI classes were made available to Java but only for plug-in development (which you have already seen).

Try this. Instead of trying to access NotesUIDocument from within Java, get the value of the EnterSendTo field in LotusScript first (via NotesUIDocument) and then pass that value to your Java code. This would require you to write a small method in your Java code to receive the value but would allow you to get around the UI class limitation.

Subject: thanks

hiRichard

thanks.I got my answer in your response.I think I must change my logic.

Subject: my mistake

My apologies, I did not realise that you were talking about plugin development. That changes a lot of course.

Unfortunately, I do not think I can be of much help for you then. My knowledge about plugin dev is very close to zero :wink:

Subject: This problem is confuse.

This problem is confuse.thanks very much. I will research it again.