Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultMenuItem: Id gets overwritten #1039

Closed
LuleJayjay opened this issue Jan 18, 2016 · 16 comments · Fixed by #6371
Closed

DefaultMenuItem: Id gets overwritten #1039

LuleJayjay opened this issue Jan 18, 2016 · 16 comments · Fixed by #6371
Assignees
Labels
enhancement Additional functionality to current component workaround A workaround has been provided
Milestone

Comments

@LuleJayjay
Copy link

in BaseMenuRenderer encodeEnd a UniqueId is being generated for every MenuElement of the MenuModel.
If an ID was set before, it gets overwritten.

@kukel
Copy link
Contributor

kukel commented Jan 18, 2016

This is not a bug but as designed. Use a DynamicMenuModel if you want to assign ids yourself. Just keep in mind thatyou need to set them everywhere, also submenu's and groups

@LuleJayjay
Copy link
Author

LuleJayjay commented Jan 19, 2016

Did you even try it with DynamicMenuModel?
It doesn't work either!!
Please post an answer you really tried before posting.

@LuleJayjay
Copy link
Author

To make the problem clearer:

if you set a String as the ID it gets still overwritten, because it needs an Integer later on:

BaseMenuRenderer PF 5.3.5 jar

protected MenuItem findMenuitem(List elements, String id) {
if(elements == null || elements.isEmpty()) {
return null;
}
else {
String[] paths = id.split(SEPARATOR);

        if(paths.length == 0)
            return null;

        int childIndex = Integer.parseInt(paths[0]);
        if(childIndex >= elements.size()) 
            return null;

        MenuElement childElement = elements.get(childIndex);

        if(paths.length == 1) {
            return (MenuItem) childElement;
        }
        else {
            String relativeIndex = id.substring(id.indexOf(SEPARATOR) + 1);

            return findMenuitem(((MenuGroup) childElement).getElements(), relativeIndex);
        }
    }
}

So why is it possible at all to set a String value as an ID?

@LuleJayjay LuleJayjay changed the title DefaultMenuItem id gets overwritten PrimeFaces 5.3.5 BUG DefaultMenuItem id gets overwritten PrimeFaces 5.3.5 Jan 22, 2016
@LuleJayjay
Copy link
Author

another Problem is, that it is not possible to see any Ids of the MenuItems in the jsf. So no JavaScript actions possible. Something is totally wrong with ids and menuItems

@kukel
Copy link
Contributor

kukel commented Feb 15, 2016

I tried... and (by 'accident') used 'integers'... Lucky me...

@Dougnlizt
Copy link

Bit by this again (using PF 6.1). Sure would be helpful if this could be fixed. I'm not off to code a work-around...

@LuleJayjay
Copy link
Author

I can post and explain my workaround tomorrow. it's not much effort.

@LuleJayjay
Copy link
Author

LuleJayjay commented Feb 13, 2018

@melloware
Copy link
Member

So I am confused. I just read that whole stack overflow and this bug ticket and here is what I think I got out of it.

  1. It doesn't work at all.
  2. It works if you use integers instead of strings for the id.
  3. DefaultMenuModel ID's overwritten is by design use DynamicMenuModel
  4. DynamicMenuModel does not work either.

Couldn't the code be modified to check if a MenuItem had an ID already if it is doesn't then it would generate a unique one?

@LuleJayjay
Copy link
Author

LuleJayjay commented Feb 13, 2018

But that's exacty what I did. I overwrote the MenuRenderer and explained how to do it. look at "Lule"s Code example

@melloware
Copy link
Member

So why not submit a PR if you have the issue fixed?

@LuleJayjay
Copy link
Author

how can I do this?

@melloware
Copy link
Member

https://help.github.com/articles/creating-a-pull-request/

@LuleJayjay
Copy link
Author

aaah thank you. Will do that in the evening then.

@liptga
Copy link

liptga commented Aug 29, 2019

@LuleJayjay which evening? Your PR would be appreciated by me as well :)

@melloware melloware changed the title BUG DefaultMenuItem id gets overwritten PrimeFaces 5.3.5 DefaultMenuItem: Id gets overwritten PrimeFaces 5.3.5 Sep 8, 2019
@melloware melloware added enhancement Additional functionality to current component workaround A workaround has been provided labels Sep 14, 2020
melloware added a commit to melloware/primefaces that referenced this issue Sep 29, 2020
@melloware melloware self-assigned this Sep 29, 2020
@melloware melloware added this to the 9.0 milestone Sep 29, 2020
@melloware melloware linked a pull request Sep 29, 2020 that will close this issue
@melloware
Copy link
Member

I just submitted a PR for this. It was quite an easy fix can @LuleJayjay @kukel please review.

@melloware melloware changed the title DefaultMenuItem: Id gets overwritten PrimeFaces 5.3.5 DefaultMenuItem: Id gets overwritten Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additional functionality to current component workaround A workaround has been provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants