-
Notifications
You must be signed in to change notification settings - Fork 20
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
Change PaginatedList.getList to return a generic typed List<E> instead of a List<Object> #105
Comments
Can you submit a pull request and with generics change can you make sure to create new list so type safety is not lost?
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Nate Kerkhofs <[email protected]>
Sent: Tuesday, January 21, 2020 11:00:17 AM
To: hazendaz/displaytag <[email protected]>
Cc: Subscribed <[email protected]>
Subject: [hazendaz/displaytag] Please change PaginatedList.getList to return a generic typed List<E> instead of a List<Object> (#105)
It appears like in version 2.0 onwards, PaginatedList.getList() was changed to use List rather than a raw List without type safety. This is problematic because if someone extends this PaginatedList interface with their own generic wrapper around your raw getList, as we do, their code won't compile and instead throw warnings and errors about generic types and casting. Instead, if at all possible, PaginatedList should return a generic List, allowing users with a generic wrapper around your PaginatedList to drop the use of this wrapper entirely.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#105?email_source=notifications&email_token=AAHODI6EMZS4A7YB7CPYWWLQ64LZDA5CNFSM4KJV3NF2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHVVCXA>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAHODI7OJDNTL6LAP7VW5CLQ64LZDANCNFSM4KJV3NFQ>.
|
Yup, ran into this as well |
Please submit a pull request for any change here. |
Original code actually was Object throughout and had warnings where it was not set, I'm looking at making that specific one use |
To add to this, 2.x line was continued from 1.2. The original author had commits added 13 years ago called 'generics and cleanups' which changed all undefined to object internally (user fgiust). |
Rather than using generics, used Row instead of Object as that is the physical object. A test case simply extends Row and that works as well so I suspect this issue is resolved as long as caller extends Row object, therefore I'm closing this as fixed on master. If any issue exists after next release, we can revisit. |
I'm sorry, but we are simply unable to extend the Row object in our current setup. It's also not necessary at all right now to extend the Row object in the current implementation of the library. |
imo, it should not be List. That completely breaks the API for all existing users, and face it, 99.999% of the users of this tag are existing users looking to get rid of old deps. I have dozens and dozens of displayTag instances; there's no way I'm spending weeks re-plumbing my code to ... extend Row?. I used to be able to just set my results to the result of a JPA query and set my size. Now I cannot set my query results due to setList<List>?! I don't get it |
I should have formatted for HTML. I mean it should not return a list of Row |
To add to my original comments, the original owner changed to List in 2014 per this commit The actual code is a Row not Object. This was fixed to properly reflect that in use case stated although user opted to not address it. Addressing that is not that complex. If you are reading data back from a database and loading it, not understanding why you simply cannot type it nor use IDE to search/replace. Its still a row. Its a paginated list after all and that is what is being displayed (rows). |
First of all, thank you for your work on this project, it is much appeciated. I don't understand where I need to extend Row. I work off 'domain objects' produced by JPA queries. We have a 'custom component' that implements PaginatedList we've use for a decade or more and it's worked great. Basically the component looks like this:
And a Controller that would use the above component, looks like this:
And on a JSP, it would be rendered like this:
Any feedback you have is greatly appreciated. Thank you |
In your example. MyObject would extend row.
Sent from my Verizon, Samsung Galaxy smartphone
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Greg Lively ***@***.***>
Sent: Saturday, November 12, 2022 1:54:15 PM
To: hazendaz/displaytag ***@***.***>
Cc: Jeremy Landis ***@***.***>; State change ***@***.***>
Subject: Re: [hazendaz/displaytag] Change PaginatedList.getList to return a generic typed List<E> instead of a List<Object> (#105)
First of all, thank you for your work on this project, it is much appeciated. I don't understand where I need to extend Row. I work off 'domain objects' produced by JPA queries. We have a 'custom component' that implements PaginatedList we've use for a decade or more and it's worked great. Basically the component looks like this:
public class DisplayTagOptions<T> implements PaginatedList {
...
@OverRide
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
...
}
And a Controller that would use the above component, looks like this:
@GetMapping(value="/list")
public String list(...) {
...
DisplayTagOptions<MyObject> displayTagOptions = new DisplayTagOptions<>(...);
displayTagOptions.setList( myService().getMyObjects(...) );
displayTagOptions.setFullListSize( myService().countAllMyObjects(...) );
model.addAttribute("displayTagOptions", displayTagOptions);
...
return getPage("list");
}
And on a JSP, it would be rendered like this:
<display:table name="displayTagOptions" htmlId="myObjectList" uid="myObjects" id="myObject" ... >
<display:column style="width:10%" title="ID">
<c:out value="${myObject.id}"/>
</display:column>
...
</display:table>
Any feedback you have is greatly appreciated. Thank you
—
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fhazendaz%2Fdisplaytag%2Fissues%2F105%23issuecomment-1312550202&data=05%7C01%7C%7C16dc64cf49b74c173b0f08dac4df4c17%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638038760574869297%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=6CqqlpV0apnLyRLxlR%2F0SICiykSVnc9pM4muTFrPJuk%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI6VNFNJGPXALUOWTPTWH7RVPANCNFSM4KJV3NFQ&data=05%7C01%7C%7C16dc64cf49b74c173b0f08dac4df4c17%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638038760574869297%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Le%2B53Xd74y1JSGktvLgKhq7B2ryY2zlLNnImHwEfKXU%3D&reserved=0>.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
It appears like in version 2.0 onwards, PaginatedList.getList() was changed to use List'''''' rather than a raw List without type safety. This is problematic because if someone extends this PaginatedList interface with their own generic wrapper around your raw getList, as we do, their code won't compile and instead throw warnings and errors about generic types and casting. Instead, if at all possible, PaginatedList should return a generic List, allowing users with a generic wrapper around your PaginatedList to drop the use of this wrapper entirely.
Is there any particular reason why PaginatedList.getList() returns a List
<Object>
rather than a List<E>
?The text was updated successfully, but these errors were encountered: