You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Thomas Lutz <ma...@gmx.at> on 2005/07/20 18:05:41 UTC
CForms: Accessing javaflow continuation or session from java event
handler...
Hi list !
I use java as flow language, not javascript. This forces me to use java
in all places, where javascript is used in the samples, and my problem
are action event listeners. I managed to write a event listener in java,
accessing all the form elements via the event param, but...
How do I access the session, or the application ?
Or even better, how do I access the instance of my javaflow class, to
set some class variables ?
As I don't like to convert all my flow code to javascript ... Help
please :-) !
thanks,
tom
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: CForms: Accessing javaflow continuation or session from java
event handler...
Posted by Thomas Lutz <ma...@gmx.at>.
Solution:
I use a formhandler for the complete form now, and not separate classes
for each action. This form handler is instantiated in javaflow, so I am
able to pass it everything I need when processing the action events.
Some code snippets (they are not really completed now, but enough to
show how it works):
Javaflow:
FormInstance form = new FormInstance("cocoon:/" + tFormName +
"_form_def.xml");
log.info("doGenericForm done generating FormInstance");
Form tForm = (Form)form.getModel();
GenericXFaceFormHandler tFormHandler = new GenericXFaceFormHandler();
tForm.setFormHandler(tFormHandler);
You need a form handler:
public class GenericXFaceFormHandler extends AbstractFormHandler {
/**
* The logger.
*/
private Log log =
LogFactory.getFactory().getInstance(this.getClass().getName());
/**
* Recieves all event and delegates depending on the command string.
* <br>
* @author tml
*
* @date 2005-07-20 tml Init <br>
*/
public void handleActionEvent(ActionEvent actionEvent) {
String tCommand = actionEvent.getActionCommand();
log.info("An ActionEvent happened with command [" + tCommand +
"]" );
if (tCommand != null && tCommand.indexOf(".") != -1)
{
String tActionCode =
tCommand.substring(0,tCommand.indexOf("."));
log.info("Action code is [" + tActionCode + "]");
if ("switch".equals(tActionCode))
{
switchFormGroups(actionEvent);
}
else if ("assignresult".equals(tActionCode))
{
assignResult(actionEvent);
}
}
}
public void handleValueChangedEvent(ValueChangedEvent
valueChangedEvent) {
// TODO Auto-generated method stub
}
Thomas Lutz schrieb:
> Hi list !
>
> I use java as flow language, not javascript. This forces me to use
> java in all places, where javascript is used in the samples, and my
> problem are action event listeners. I managed to write a event
> listener in java, accessing all the form elements via the event param,
> but...
>
> How do I access the session, or the application ?
>
> Or even better, how do I access the instance of my javaflow class, to
> set some class variables ?
>
> As I don't like to convert all my flow code to javascript ... Help
> please :-) !
>
> thanks,
> tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org