You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Bjørn Stenfeldt (JIRA)" <de...@myfaces.apache.org> on 2006/07/06 13:33:29 UTC
[jira] Created: (TOMAHAWK-521) Values from checkboxes not received
on submit, when branches are collapsed.
Values from checkboxes not received on submit, when branches are collapsed.
---------------------------------------------------------------------------
Key: TOMAHAWK-521
URL: http://issues.apache.org/jira/browse/TOMAHAWK-521
Project: MyFaces Tomahawk
Type: Bug
Components: Tree2
Versions: 1.1.3
Environment: NetBean IDE 5.0
JSF 1.1 RI
Sun Java System Application Server 9
Java EE SDK 5 Windows
Reporter: Bjørn Stenfeldt
Priority: Minor
I think this issue is best explained with an example, so here goes...
I have a tree root. It is not expanded. It has a checkbox, which is not checked.
[+][ ] root
Then I expand the root, which reveals 2 children. The children too have checkboxes that are not checked.
[-][ ] root
|
- [ ] child1
|
- [ ] child2
I now check the root and the 2 children. If I were to submit now, everything would work as expected. Values from all 3 checkboxes would be received. But I won't...
[-][x] root
|
- [x] child1
|
- [x] child2
... Instead I will collaps the tree again, leaving only the root visible.
[+][x] root
Finally, I submit the tree. In my backing bean I will then only receive the checkbox value of the root. The checkbox value of child1 and child2 is not submitted. Values from the 2 children do exist in the request scope, but for some reason the backing bean is not set with them.
Here follows the code I'm using...
JSF:
<html:form id="createHost">
<tomahawk:tree2 id="clientTree" value="#{ModuleBean.moduleHierarchy}"
var="node" showRootNode="false" clientSideToggle="true">
<core:facet name="root">
<html:panelGroup>
<tomahawk:htmlTag value="div">
<html:outputText value="#{node.description}"/>
<html:outputText value=" (#{node.childCount})"
styleClass="childCount"
rendered="#{!empty node.children}"/>
</tomahawk:htmlTag>
</html:panelGroup>
</core:facet>
<core:facet name="module">
<html:panelGroup>
<tomahawk:htmlTag value="div">
<tomahawk:selectManyCheckbox id="moduleId" layout="spread"
converter="#{HostBean.moduleIdTreeConverter}"
value="#{HostBean.moduleId}">
<tomahawk:treeCheckbox for="moduleId"
itemValue="#{node.identifier}"
itemLabel="#{node.description}"/>
</tomahawk:selectManyCheckbox>
<html:outputText value=" (#{node.childCount})"
styleClass="childCount"
rendered="#{!empty node.children}"/>
</tomahawk:htmlTag>
</html:panelGroup>
</core:facet>
</tomahawk:tree2>
<html:commandButton value="OK" action="#{HostBean.updateHostAction}"
style="width: 25%;" styleClass="button"/>
</html:form>
HostBean:
private void addModuleId(String moduleId) {
if (moduleId != null && !moduleId.equals(""))
if (!this.moduleId.contains(moduleId))
this.moduleId.add(moduleId);
}
public List getModuleId() {
return moduleId;
}
public void setModuleId(List moduleId) {
for (int i = 0; i < moduleId.size(); i++) {
String value = (String)moduleId.get(i);
addModuleId(value);
}
}
public Converter getModuleIdTreeConverter() {
return new Converter() {
public Object getAsObject(FacesContext context,
UIComponent component, String newValue)
throws ConverterException {
addModuleId(newValue);
return newValue;
}
public String getAsString(FacesContext context,
UIComponent component, Object value)
throws ConverterException {
return (String)value;
}
};
}
public void loadHost(ActionEvent event) {
/* Initializes data, when the user first clicks the edit button on a
host.
Loads both host data and modules. Modules are added using
the addModuleId(String) method. */
}
public String updateHostAction() {
CachingServiceLocator csl = CachingServiceLocator.getInstance();
HostLocal hostLocal = csl.lookupHostBean();
Integer[] moduleId = new Integer[this.moduleId.size()];
for (int i = 0; i < moduleId.length; i++) {
moduleId[i] = Integer.valueOf((String)this.moduleId.get(i));
}
try {
hostLocal.updateHost(id, languageId, currencyId,
moduleId, name, mail, address);
}
catch (UpdateException ue) {}
return "success";
}
ModuleBean:
private void addChildModules(TreeNode node, TOList modules) {
for (int i = 0; i < modules.getLimitedSize(); i++) {
ModuleTO module = (ModuleTO)modules.get(i);
TreeNode child = new TreeNodeBase("module",
module.getName(), String.valueOf(module.getId()), false);
node.getChildren().add(child);
addChildModules(child, module.getChildModules());
}
}
public TreeNode getModuleHierarchy() {
CachingServiceLocator csl = CachingServiceLocator.getInstance();
ModuleLocal ml = csl.lookupModuleBean();
TreeNode base = new TreeNodeBase("root", "ROOT", false);
addChildModules(base, ml.loadModuleHierarchy());
return base;
}
--
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
[jira] Commented: (TOMAHAWK-521) Values from checkboxes not
received on submit, when branches are collapsed.
Posted by "Bjørn Stenfeldt (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/TOMAHAWK-521?page=comments#action_12434926 ]
Bjørn Stenfeldt commented on TOMAHAWK-521:
------------------------------------------
I had to find a work around too. Its a bit of work, but the best I could come up with. Here is a simplified example of what I did:
JSF:
<script language="JavaScript" type="text/javascript">
function toggleTreeCheckbox(containerId, checkboxId) {
var container = document.getElementById(containerId);
var checkbox= document.getElementById(checkboxId);
if (container != null && checkbox != null) {
var checkboxValue = "{" + checkbox.value + "}";
if (container.value.indexOf(checkboxValue) == -1) {
container.value = container.value + checkboxValue;
}
else {
var splitValue = container.value.split(checkboxValue);
container.value = splitValue[0] + splitValue[1];
}
}
}
</script>
<html:form id="myForm">
<html:inputHidden id="idArray" value="#{BackingBean.idArray}"/>
<tomahawk:tree2 id="tree" value="#{BackingBean.hierarchy}" var="node"
showRootNode="false" preserveToggle="true" clientSideToggle="true">
<core:facet name="root">
<tomahawk:htmlTag value="div">
<tomahawk:selectManyCheckbox id="id" layout="spread"
converter="#{BackingBean.idTreeConverter}"
value="#{BackingBean.id}"
onchange="toggleTreeCheckbox('myForm:idArray', this.id);">
<tomahawk:treeCheckbox for="id"
itemValue="#{node.identifier}"
itemLabel="#{node.description}"/>
</tomahawk:selectManyCheckbox>
</tomahawk:htmlTag>
</core:facet>
</tomahawk:tree2>
Then when submitting, I would get the ids from the idArray string. Each individual id is surrounded by { and }. Its a mess, so I really hope they will fix this.
Another solution might be to simple get the ids from the request scope and setting them in your backing bean yourself. I didnt have time to thing about this problem too much. Deadlines you know... :-/
> Values from checkboxes not received on submit, when branches are collapsed.
> ---------------------------------------------------------------------------
>
> Key: TOMAHAWK-521
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-521
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Tree2
> Affects Versions: 1.1.3
> Environment: NetBean IDE 5.0
> JSF 1.1 RI
> Sun Java System Application Server 9
> Java EE SDK 5 Windows
> Reporter: Bjørn Stenfeldt
> Priority: Minor
>
> I think this issue is best explained with an example, so here goes...
> I have a tree root. It is not expanded. It has a checkbox, which is not checked.
> [+][ ] root
> Then I expand the root, which reveals 2 children. The children too have checkboxes that are not checked.
> [-][ ] root
> |
> - [ ] child1
> |
> - [ ] child2
> I now check the root and the 2 children. If I were to submit now, everything would work as expected. Values from all 3 checkboxes would be received. But I won't...
> [-][x] root
> |
> - [x] child1
> |
> - [x] child2
> ... Instead I will collaps the tree again, leaving only the root visible.
> [+][x] root
> Finally, I submit the tree. In my backing bean I will then only receive the checkbox value of the root. The checkbox value of child1 and child2 is not submitted. Values from the 2 children do exist in the request scope, but for some reason the backing bean is not set with them.
> Here follows the code I'm using...
> JSF:
> <html:form id="createHost">
> <tomahawk:tree2 id="clientTree" value="#{ModuleBean.moduleHierarchy}"
> var="node" showRootNode="false" clientSideToggle="true">
> <core:facet name="root">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <html:outputText value="#{node.description}"/>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> <core:facet name="module">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <tomahawk:selectManyCheckbox id="moduleId" layout="spread"
> converter="#{HostBean.moduleIdTreeConverter}"
> value="#{HostBean.moduleId}">
> <tomahawk:treeCheckbox for="moduleId"
> itemValue="#{node.identifier}"
> itemLabel="#{node.description}"/>
> </tomahawk:selectManyCheckbox>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> </tomahawk:tree2>
> <html:commandButton value="OK" action="#{HostBean.updateHostAction}"
> style="width: 25%;" styleClass="button"/>
> </html:form>
> HostBean:
> private void addModuleId(String moduleId) {
> if (moduleId != null && !moduleId.equals(""))
> if (!this.moduleId.contains(moduleId))
> this.moduleId.add(moduleId);
> }
> public List getModuleId() {
> return moduleId;
> }
> public void setModuleId(List moduleId) {
> for (int i = 0; i < moduleId.size(); i++) {
> String value = (String)moduleId.get(i);
> addModuleId(value);
> }
> }
> public Converter getModuleIdTreeConverter() {
> return new Converter() {
> public Object getAsObject(FacesContext context,
> UIComponent component, String newValue)
> throws ConverterException {
> addModuleId(newValue);
> return newValue;
> }
> public String getAsString(FacesContext context,
> UIComponent component, Object value)
> throws ConverterException {
> return (String)value;
> }
> };
> }
> public void loadHost(ActionEvent event) {
> /* Initializes data, when the user first clicks the edit button on a
> host.
> Loads both host data and modules. Modules are added using
> the addModuleId(String) method. */
> }
> public String updateHostAction() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> HostLocal hostLocal = csl.lookupHostBean();
> Integer[] moduleId = new Integer[this.moduleId.size()];
> for (int i = 0; i < moduleId.length; i++) {
> moduleId[i] = Integer.valueOf((String)this.moduleId.get(i));
> }
> try {
> hostLocal.updateHost(id, languageId, currencyId,
> moduleId, name, mail, address);
> }
> catch (UpdateException ue) {}
> return "success";
> }
> ModuleBean:
> private void addChildModules(TreeNode node, TOList modules) {
> for (int i = 0; i < modules.getLimitedSize(); i++) {
> ModuleTO module = (ModuleTO)modules.get(i);
> TreeNode child = new TreeNodeBase("module",
> module.getName(), String.valueOf(module.getId()), false);
> node.getChildren().add(child);
> addChildModules(child, module.getChildModules());
> }
> }
> public TreeNode getModuleHierarchy() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> ModuleLocal ml = csl.lookupModuleBean();
> TreeNode base = new TreeNodeBase("root", "ROOT", false);
> addChildModules(base, ml.loadModuleHierarchy());
> return base;
> }
--
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
[jira] Commented: (TOMAHAWK-521) Values from checkboxes not
received on submit, when branches are collapsed.
Posted by "Olga Penina (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/TOMAHAWK-521?page=comments#action_12441842 ]
Olga Penina commented on TOMAHAWK-521:
--------------------------------------
It's not true that the checkboxes are not being submitted when the node is collapsed - they are.
The problem is that during the processDecodes() phase the TreeWalker ignores the collapsed nodes.
Like some of you we've discovered this a bit too late. To make the fix as painless as possible, I just made a new tag ( Tree3 ! ) and a matching UI component that extends
org.apache.myfaces.custom.tree2.HtmlTree and the only method I had to override was processNodes():
<code>
protected void processNodes(FacesContext...)
{
UIComponent facet = null;
TreeWalker walker = getDataModel().getTreeWalker();
walker.reset();
walker.setTree(this);
// This will make it see all the collapsed nodes:
walker.setCheckState(false);
// the rest is the same...
</code>
I am sure that there is a way to configure the TreeWalker from the DataModel also.
"Problems cannot be solved at the same level of awareness that created
them." (!)
> Values from checkboxes not received on submit, when branches are collapsed.
> ---------------------------------------------------------------------------
>
> Key: TOMAHAWK-521
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-521
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Tree2
> Affects Versions: 1.1.3
> Environment: NetBean IDE 5.0
> JSF 1.1 RI
> Sun Java System Application Server 9
> Java EE SDK 5 Windows
> Reporter: Bjørn Stenfeldt
> Priority: Minor
>
> I think this issue is best explained with an example, so here goes...
> I have a tree root. It is not expanded. It has a checkbox, which is not checked.
> [+][ ] root
> Then I expand the root, which reveals 2 children. The children too have checkboxes that are not checked.
> [-][ ] root
> |
> - [ ] child1
> |
> - [ ] child2
> I now check the root and the 2 children. If I were to submit now, everything would work as expected. Values from all 3 checkboxes would be received. But I won't...
> [-][x] root
> |
> - [x] child1
> |
> - [x] child2
> ... Instead I will collaps the tree again, leaving only the root visible.
> [+][x] root
> Finally, I submit the tree. In my backing bean I will then only receive the checkbox value of the root. The checkbox value of child1 and child2 is not submitted. Values from the 2 children do exist in the request scope, but for some reason the backing bean is not set with them.
> Here follows the code I'm using...
> JSF:
> <html:form id="createHost">
> <tomahawk:tree2 id="clientTree" value="#{ModuleBean.moduleHierarchy}"
> var="node" showRootNode="false" clientSideToggle="true">
> <core:facet name="root">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <html:outputText value="#{node.description}"/>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> <core:facet name="module">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <tomahawk:selectManyCheckbox id="moduleId" layout="spread"
> converter="#{HostBean.moduleIdTreeConverter}"
> value="#{HostBean.moduleId}">
> <tomahawk:treeCheckbox for="moduleId"
> itemValue="#{node.identifier}"
> itemLabel="#{node.description}"/>
> </tomahawk:selectManyCheckbox>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> </tomahawk:tree2>
> <html:commandButton value="OK" action="#{HostBean.updateHostAction}"
> style="width: 25%;" styleClass="button"/>
> </html:form>
> HostBean:
> private void addModuleId(String moduleId) {
> if (moduleId != null && !moduleId.equals(""))
> if (!this.moduleId.contains(moduleId))
> this.moduleId.add(moduleId);
> }
> public List getModuleId() {
> return moduleId;
> }
> public void setModuleId(List moduleId) {
> for (int i = 0; i < moduleId.size(); i++) {
> String value = (String)moduleId.get(i);
> addModuleId(value);
> }
> }
> public Converter getModuleIdTreeConverter() {
> return new Converter() {
> public Object getAsObject(FacesContext context,
> UIComponent component, String newValue)
> throws ConverterException {
> addModuleId(newValue);
> return newValue;
> }
> public String getAsString(FacesContext context,
> UIComponent component, Object value)
> throws ConverterException {
> return (String)value;
> }
> };
> }
> public void loadHost(ActionEvent event) {
> /* Initializes data, when the user first clicks the edit button on a
> host.
> Loads both host data and modules. Modules are added using
> the addModuleId(String) method. */
> }
> public String updateHostAction() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> HostLocal hostLocal = csl.lookupHostBean();
> Integer[] moduleId = new Integer[this.moduleId.size()];
> for (int i = 0; i < moduleId.length; i++) {
> moduleId[i] = Integer.valueOf((String)this.moduleId.get(i));
> }
> try {
> hostLocal.updateHost(id, languageId, currencyId,
> moduleId, name, mail, address);
> }
> catch (UpdateException ue) {}
> return "success";
> }
> ModuleBean:
> private void addChildModules(TreeNode node, TOList modules) {
> for (int i = 0; i < modules.getLimitedSize(); i++) {
> ModuleTO module = (ModuleTO)modules.get(i);
> TreeNode child = new TreeNodeBase("module",
> module.getName(), String.valueOf(module.getId()), false);
> node.getChildren().add(child);
> addChildModules(child, module.getChildModules());
> }
> }
> public TreeNode getModuleHierarchy() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> ModuleLocal ml = csl.lookupModuleBean();
> TreeNode base = new TreeNodeBase("root", "ROOT", false);
> addChildModules(base, ml.loadModuleHierarchy());
> return base;
> }
--
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
[jira] Updated: (TOMAHAWK-521) Values from checkboxes not received
on submit, when branches are collapsed.
Posted by "Grant Smith (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/TOMAHAWK-521?page=all ]
Grant Smith updated TOMAHAWK-521:
---------------------------------
Status: Resolved (was: Patch Available)
Resolution: Fixed
Patch applied. Thanks for finding this !
> Values from checkboxes not received on submit, when branches are collapsed.
> ---------------------------------------------------------------------------
>
> Key: TOMAHAWK-521
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-521
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Tree2
> Affects Versions: 1.1.3
> Environment: NetBean IDE 5.0
> JSF 1.1 RI
> Sun Java System Application Server 9
> Java EE SDK 5 Windows
> Reporter: Bjørn Stenfeldt
> Assigned To: Grant Smith
> Priority: Critical
> Attachments: TOMAHAWK-521.patch
>
>
> I think this issue is best explained with an example, so here goes...
> I have a tree root. It is not expanded. It has a checkbox, which is not checked.
> [+][ ] root
> Then I expand the root, which reveals 2 children. The children too have checkboxes that are not checked.
> [-][ ] root
> |
> - [ ] child1
> |
> - [ ] child2
> I now check the root and the 2 children. If I were to submit now, everything would work as expected. Values from all 3 checkboxes would be received. But I won't...
> [-][x] root
> |
> - [x] child1
> |
> - [x] child2
> ... Instead I will collaps the tree again, leaving only the root visible.
> [+][x] root
> Finally, I submit the tree. In my backing bean I will then only receive the checkbox value of the root. The checkbox value of child1 and child2 is not submitted. Values from the 2 children do exist in the request scope, but for some reason the backing bean is not set with them.
> Here follows the code I'm using...
> JSF:
> <html:form id="createHost">
> <tomahawk:tree2 id="clientTree" value="#{ModuleBean.moduleHierarchy}"
> var="node" showRootNode="false" clientSideToggle="true">
> <core:facet name="root">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <html:outputText value="#{node.description}"/>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> <core:facet name="module">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <tomahawk:selectManyCheckbox id="moduleId" layout="spread"
> converter="#{HostBean.moduleIdTreeConverter}"
> value="#{HostBean.moduleId}">
> <tomahawk:treeCheckbox for="moduleId"
> itemValue="#{node.identifier}"
> itemLabel="#{node.description}"/>
> </tomahawk:selectManyCheckbox>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> </tomahawk:tree2>
> <html:commandButton value="OK" action="#{HostBean.updateHostAction}"
> style="width: 25%;" styleClass="button"/>
> </html:form>
> HostBean:
> private void addModuleId(String moduleId) {
> if (moduleId != null && !moduleId.equals(""))
> if (!this.moduleId.contains(moduleId))
> this.moduleId.add(moduleId);
> }
> public List getModuleId() {
> return moduleId;
> }
> public void setModuleId(List moduleId) {
> for (int i = 0; i < moduleId.size(); i++) {
> String value = (String)moduleId.get(i);
> addModuleId(value);
> }
> }
> public Converter getModuleIdTreeConverter() {
> return new Converter() {
> public Object getAsObject(FacesContext context,
> UIComponent component, String newValue)
> throws ConverterException {
> addModuleId(newValue);
> return newValue;
> }
> public String getAsString(FacesContext context,
> UIComponent component, Object value)
> throws ConverterException {
> return (String)value;
> }
> };
> }
> public void loadHost(ActionEvent event) {
> /* Initializes data, when the user first clicks the edit button on a
> host.
> Loads both host data and modules. Modules are added using
> the addModuleId(String) method. */
> }
> public String updateHostAction() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> HostLocal hostLocal = csl.lookupHostBean();
> Integer[] moduleId = new Integer[this.moduleId.size()];
> for (int i = 0; i < moduleId.length; i++) {
> moduleId[i] = Integer.valueOf((String)this.moduleId.get(i));
> }
> try {
> hostLocal.updateHost(id, languageId, currencyId,
> moduleId, name, mail, address);
> }
> catch (UpdateException ue) {}
> return "success";
> }
> ModuleBean:
> private void addChildModules(TreeNode node, TOList modules) {
> for (int i = 0; i < modules.getLimitedSize(); i++) {
> ModuleTO module = (ModuleTO)modules.get(i);
> TreeNode child = new TreeNodeBase("module",
> module.getName(), String.valueOf(module.getId()), false);
> node.getChildren().add(child);
> addChildModules(child, module.getChildModules());
> }
> }
> public TreeNode getModuleHierarchy() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> ModuleLocal ml = csl.lookupModuleBean();
> TreeNode base = new TreeNodeBase("root", "ROOT", false);
> addChildModules(base, ml.loadModuleHierarchy());
> return base;
> }
--
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
[jira] Resolved: (TOMAHAWK-521) Values from checkboxes not received
on submit, when branches are collapsed.
Posted by "Grant Smith (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/TOMAHAWK-521?page=all ]
Grant Smith resolved TOMAHAWK-521.
----------------------------------
Fix Version/s: 1.1.5-SNAPSHOT
Resolution: Fixed
Fix version...
> Values from checkboxes not received on submit, when branches are collapsed.
> ---------------------------------------------------------------------------
>
> Key: TOMAHAWK-521
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-521
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Tree2
> Affects Versions: 1.1.3
> Environment: NetBean IDE 5.0
> JSF 1.1 RI
> Sun Java System Application Server 9
> Java EE SDK 5 Windows
> Reporter: Bjørn Stenfeldt
> Assigned To: Grant Smith
> Priority: Critical
> Fix For: 1.1.5-SNAPSHOT
>
> Attachments: TOMAHAWK-521.patch
>
>
> I think this issue is best explained with an example, so here goes...
> I have a tree root. It is not expanded. It has a checkbox, which is not checked.
> [+][ ] root
> Then I expand the root, which reveals 2 children. The children too have checkboxes that are not checked.
> [-][ ] root
> |
> - [ ] child1
> |
> - [ ] child2
> I now check the root and the 2 children. If I were to submit now, everything would work as expected. Values from all 3 checkboxes would be received. But I won't...
> [-][x] root
> |
> - [x] child1
> |
> - [x] child2
> ... Instead I will collaps the tree again, leaving only the root visible.
> [+][x] root
> Finally, I submit the tree. In my backing bean I will then only receive the checkbox value of the root. The checkbox value of child1 and child2 is not submitted. Values from the 2 children do exist in the request scope, but for some reason the backing bean is not set with them.
> Here follows the code I'm using...
> JSF:
> <html:form id="createHost">
> <tomahawk:tree2 id="clientTree" value="#{ModuleBean.moduleHierarchy}"
> var="node" showRootNode="false" clientSideToggle="true">
> <core:facet name="root">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <html:outputText value="#{node.description}"/>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> <core:facet name="module">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <tomahawk:selectManyCheckbox id="moduleId" layout="spread"
> converter="#{HostBean.moduleIdTreeConverter}"
> value="#{HostBean.moduleId}">
> <tomahawk:treeCheckbox for="moduleId"
> itemValue="#{node.identifier}"
> itemLabel="#{node.description}"/>
> </tomahawk:selectManyCheckbox>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> </tomahawk:tree2>
> <html:commandButton value="OK" action="#{HostBean.updateHostAction}"
> style="width: 25%;" styleClass="button"/>
> </html:form>
> HostBean:
> private void addModuleId(String moduleId) {
> if (moduleId != null && !moduleId.equals(""))
> if (!this.moduleId.contains(moduleId))
> this.moduleId.add(moduleId);
> }
> public List getModuleId() {
> return moduleId;
> }
> public void setModuleId(List moduleId) {
> for (int i = 0; i < moduleId.size(); i++) {
> String value = (String)moduleId.get(i);
> addModuleId(value);
> }
> }
> public Converter getModuleIdTreeConverter() {
> return new Converter() {
> public Object getAsObject(FacesContext context,
> UIComponent component, String newValue)
> throws ConverterException {
> addModuleId(newValue);
> return newValue;
> }
> public String getAsString(FacesContext context,
> UIComponent component, Object value)
> throws ConverterException {
> return (String)value;
> }
> };
> }
> public void loadHost(ActionEvent event) {
> /* Initializes data, when the user first clicks the edit button on a
> host.
> Loads both host data and modules. Modules are added using
> the addModuleId(String) method. */
> }
> public String updateHostAction() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> HostLocal hostLocal = csl.lookupHostBean();
> Integer[] moduleId = new Integer[this.moduleId.size()];
> for (int i = 0; i < moduleId.length; i++) {
> moduleId[i] = Integer.valueOf((String)this.moduleId.get(i));
> }
> try {
> hostLocal.updateHost(id, languageId, currencyId,
> moduleId, name, mail, address);
> }
> catch (UpdateException ue) {}
> return "success";
> }
> ModuleBean:
> private void addChildModules(TreeNode node, TOList modules) {
> for (int i = 0; i < modules.getLimitedSize(); i++) {
> ModuleTO module = (ModuleTO)modules.get(i);
> TreeNode child = new TreeNodeBase("module",
> module.getName(), String.valueOf(module.getId()), false);
> node.getChildren().add(child);
> addChildModules(child, module.getChildModules());
> }
> }
> public TreeNode getModuleHierarchy() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> ModuleLocal ml = csl.lookupModuleBean();
> TreeNode base = new TreeNodeBase("root", "ROOT", false);
> addChildModules(base, ml.loadModuleHierarchy());
> return base;
> }
--
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
[jira] Reopened: (TOMAHAWK-521) Values from checkboxes not received
on submit, when branches are collapsed.
Posted by "Grant Smith (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/TOMAHAWK-521?page=all ]
Grant Smith reopened TOMAHAWK-521:
----------------------------------
Forgot to state the fix version...
> Values from checkboxes not received on submit, when branches are collapsed.
> ---------------------------------------------------------------------------
>
> Key: TOMAHAWK-521
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-521
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Tree2
> Affects Versions: 1.1.3
> Environment: NetBean IDE 5.0
> JSF 1.1 RI
> Sun Java System Application Server 9
> Java EE SDK 5 Windows
> Reporter: Bjørn Stenfeldt
> Assigned To: Grant Smith
> Priority: Critical
> Fix For: 1.1.5-SNAPSHOT
>
> Attachments: TOMAHAWK-521.patch
>
>
> I think this issue is best explained with an example, so here goes...
> I have a tree root. It is not expanded. It has a checkbox, which is not checked.
> [+][ ] root
> Then I expand the root, which reveals 2 children. The children too have checkboxes that are not checked.
> [-][ ] root
> |
> - [ ] child1
> |
> - [ ] child2
> I now check the root and the 2 children. If I were to submit now, everything would work as expected. Values from all 3 checkboxes would be received. But I won't...
> [-][x] root
> |
> - [x] child1
> |
> - [x] child2
> ... Instead I will collaps the tree again, leaving only the root visible.
> [+][x] root
> Finally, I submit the tree. In my backing bean I will then only receive the checkbox value of the root. The checkbox value of child1 and child2 is not submitted. Values from the 2 children do exist in the request scope, but for some reason the backing bean is not set with them.
> Here follows the code I'm using...
> JSF:
> <html:form id="createHost">
> <tomahawk:tree2 id="clientTree" value="#{ModuleBean.moduleHierarchy}"
> var="node" showRootNode="false" clientSideToggle="true">
> <core:facet name="root">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <html:outputText value="#{node.description}"/>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> <core:facet name="module">
> <html:panelGroup>
> <tomahawk:htmlTag value="div">
> <tomahawk:selectManyCheckbox id="moduleId" layout="spread"
> converter="#{HostBean.moduleIdTreeConverter}"
> value="#{HostBean.moduleId}">
> <tomahawk:treeCheckbox for="moduleId"
> itemValue="#{node.identifier}"
> itemLabel="#{node.description}"/>
> </tomahawk:selectManyCheckbox>
> <html:outputText value=" (#{node.childCount})"
> styleClass="childCount"
> rendered="#{!empty node.children}"/>
> </tomahawk:htmlTag>
> </html:panelGroup>
> </core:facet>
> </tomahawk:tree2>
> <html:commandButton value="OK" action="#{HostBean.updateHostAction}"
> style="width: 25%;" styleClass="button"/>
> </html:form>
> HostBean:
> private void addModuleId(String moduleId) {
> if (moduleId != null && !moduleId.equals(""))
> if (!this.moduleId.contains(moduleId))
> this.moduleId.add(moduleId);
> }
> public List getModuleId() {
> return moduleId;
> }
> public void setModuleId(List moduleId) {
> for (int i = 0; i < moduleId.size(); i++) {
> String value = (String)moduleId.get(i);
> addModuleId(value);
> }
> }
> public Converter getModuleIdTreeConverter() {
> return new Converter() {
> public Object getAsObject(FacesContext context,
> UIComponent component, String newValue)
> throws ConverterException {
> addModuleId(newValue);
> return newValue;
> }
> public String getAsString(FacesContext context,
> UIComponent component, Object value)
> throws ConverterException {
> return (String)value;
> }
> };
> }
> public void loadHost(ActionEvent event) {
> /* Initializes data, when the user first clicks the edit button on a
> host.
> Loads both host data and modules. Modules are added using
> the addModuleId(String) method. */
> }
> public String updateHostAction() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> HostLocal hostLocal = csl.lookupHostBean();
> Integer[] moduleId = new Integer[this.moduleId.size()];
> for (int i = 0; i < moduleId.length; i++) {
> moduleId[i] = Integer.valueOf((String)this.moduleId.get(i));
> }
> try {
> hostLocal.updateHost(id, languageId, currencyId,
> moduleId, name, mail, address);
> }
> catch (UpdateException ue) {}
> return "success";
> }
> ModuleBean:
> private void addChildModules(TreeNode node, TOList modules) {
> for (int i = 0; i < modules.getLimitedSize(); i++) {
> ModuleTO module = (ModuleTO)modules.get(i);
> TreeNode child = new TreeNodeBase("module",
> module.getName(), String.valueOf(module.getId()), false);
> node.getChildren().add(child);
> addChildModules(child, module.getChildModules());
> }
> }
> public TreeNode getModuleHierarchy() {
> CachingServiceLocator csl = CachingServiceLocator.getInstance();
> ModuleLocal ml = csl.lookupModuleBean();
> TreeNode base = new TreeNodeBase("root", "ROOT", false);
> addChildModules(base, ml.loadModuleHierarchy());
> return base;
> }
--
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