[
http://issues.apache.org/jira/browse/MYFACES-27?page=comments#action_12329646 ]
Martin Marinschek commented on MYFACES-27:
------------------------------------------
My suggestion would be the same as the one by Tobias below, except I wouldn't
provide a formId, but instead take the form which is the ancestor of this
jsCookMenu.
regards,
Martin
Original suggestion by Tobias (copied over from MYFACES-219):
The HtmlCommandJSCookMenu component renders its own html-form called
linkDummyForm. If it is embedded into another form the other form (including
its children) will never be decoded because its submitted-property is set to
false in UIForm.decode().
It should be possible to control wether the HtmlCommandJSCookMenu component
should render its own form or should be part of an existing form.
In my application I developed a solution for this problem.
1. The HtmlJSCookMenuTag needs a new property, which holds the id of the form
which is the parent of this tag. I called it formId. This new property has to
be added in HtmlJSCookMenuTag.setProperties().
2. The HtmlCommandJSCookMenu component needs the formId property, described in
step 1, aswell. And it has to be added to saveState() and restoreState()
3. The HtmlJSCookMenuRenderer has to read the formId of its component.
3.1 If it is not set everything stays as it is in the moment. That means:
DummyFormResponseWriter.writeDummyForm is set to true, which causes the writer
to append a linkDummyForm at the end of the rendered html page.
3.2 If it is set writeDummyForm of DummyFormResponseWriter is set to false.
Instead of rendering a form (called linkDummyForm) at the end of the rendered
html page, there are only two input-fields, which will be rendered within
HtmlJSCookMenuRenderer.encodeChildren(): jscook_action, which holds the choosed
actionstring from the menu (in the moment it is rendered as part of the
linkDummyForm only) and a new field named jscook_form_id which gets the formId
of the HtmlCommandJSCookMenu component.
4. The cmItemMouseUp function within the JavaScript library named JSCookMenu.js
needs to read the jscook_form_id field, rendered previously in step 3.2 like
this:
-------begin code--------------------------------------------
var formId = null;
var dummyForm = null;
var inputFormIds = document.getElementsByName('jscook_form_id');
if (inputFormIds.length > 0) {
formId = inputFormIds[0].value;
dummyForm = document.forms[formId];
} else {
dummyForm = document.forms['linkDummyForm'];
}
dummyForm.elements['jscook_action'].value = link;
dummyForm.submit();
------------end code-------------------------
5. Moreover it is needed to configure the immediate attribute of the component
in the HtmlJSCookMenuTag. In the moment it is hardcoded in
HtmlCommandJSCookMenu. There exists another issue here in the database
concerning this point.
> JSCookmenu cannot be used for storing data
> ------------------------------------------
>
> Key: MYFACES-27
> URL: http://issues.apache.org/jira/browse/MYFACES-27
> Project: MyFaces
> Type: Bug
> Versions: 1.0.7 beta
> Environment: JBoss 4.0
> Assignee: Thomas Spiegl
>
> JSCookmenu has hardcoded "immediate" attribute on "true". This cause that an
> action, which should store data from the view, is executed after the
> apply_request_values-phase instead of the application-execute-phase. But at
> that time the model values are not updated with the view-values, so a empty
> objekt is stored.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira