2

In my java project using DD4T 2 beta, I would like to get the Page Schema object from a page object.

Unfortunately, the Page interface (https://github.com/dd4t/dd4t-2-java/blob/develop/dd4t-api/src/main/java/org/dd4t/contentmodel/Page.java) does not provide a getter for the schema. However, the schema object appears to be available in the page implementation classes, since it inherits from the BaseRepositoryLocalItem (https://github.com/dd4t/dd4t-2-java/blob/b3799b2869de908c05cddd969a0d4fc048448441/dd4t-core/src/main/java/org/dd4t/contentmodel/impl/BaseRepositoryLocalItem.java)

This means that, if i want to access the Schema property, I should cast my Page object to a PageImpl object. Is this the correct way to do it, or is there a better way ?

some sample code

public function getPageSchema(org.dd4t.contentmodel.Page genericPage)
{
    // omitted null checks & checks that genericPage is of type PageImpl
    Schema pageSchema = ((PageImpl)genericPage).getSchema();
}

1 Answer 1

2

You're right - the repositorylocalitem interface doesn't expose the necessary getSchema() method you'd expect to see based on the implementation. This would be the correct way out indeed.

On a side note, could you raise a bug at dd4t-2 for this? It's a simple enough fix to include in the framework.

2
  • 1
    or solve it, and create a pull request :)
    – user219
    Commented Sep 21, 2015 at 7:04
  • Fixed in version 2.0.6.
    – Raimond
    Commented Oct 24, 2016 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.