Expand my Community achievements bar.

Model.json

Avatar

Level 2

I want my custom page properties to include in the json.model ootb page 

How can I do that?


I already create a new field in dialog , and try to expose them but still don't works. 

 

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;

@Model(
    adaptables = SlingHttpServletRequest.class,
    adapters = ComponentExporter.class,
    defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL,
    resourceType = "core/wcm/components/page/v3/page"
)
@Exporter(
    name = ExporterConstants.SLING_MODEL_EXPORTER_NAME,
    extensions = ExporterConstants.SLING_MODEL_EXTENSION
)
public class ContentPageModel implements ComponentExporter  {

  static final String RESOURCE_TYPE = "core/wcm/components/page/v3/page";
  // Custom properties
  @ValueMapValue
  private String pageTitleContentPage;

  @ValueMapValue
  private String pageDescription;

  @ValueMapValue
  private String titleTag;

  @ValueMapValue
  private String date;

  public String getPageTitleContentPage() {
    return pageTitleContentPage;
  }

  public String getPageDescription() {
    return pageDescription;
  }

  public String getTitleTag() {
    return titleTag;
  }

  public void setPageTitleContentPage(String pageTitleContentPage) {
    this.pageTitleContentPage = pageTitleContentPage;
  }

  public void setPageDescription(String pageDescription) {
    this.pageDescription = pageDescription;
  }

  public void setTitleTag(String titleTag) {
    this.titleTag = titleTag;
  }

  public void setDate(String date) {
    this.date = date;
  }

  public String getDate() {
    return date;
  }

  @Override
  public String getExportedType() {
    return "core/wcm/components/page/v3/page";
  }
}

My Expectation is it included in here

Fendy__0-1731146739191.png

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

4 Replies

Avatar

Employee Advisor

It seems that you want to override the exporter for the v3 page template of the Core Components. And most likely there is already one for it, and for that reason it's not working.

 

I would recommend that you define for your own pages a dedicated resourcetype (you can define the v3 page as supertype) and use it. And then you can define your own sling model for it.

Avatar

Level 2

I'm already try using my own resource type , but now the json only show this it don't show the OOTB exporter , do you know how can I solve this issue ?

So I also want to include the ootb exporter

Fendy__0-1731297217115.png

 

Avatar

Community Advisor

HI @Fendy_ 
Can you share the sling Model for how did you extend the new page component with v3/page?

 



Arun Patidar

Avatar

Administrator

@Fendy_ Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni