Get video path | Community
Skip to main content
Level 3
October 6, 2021
Solved

Get video path

  • October 6, 2021
  • 2 replies
  • 3616 views

Hi,

I am trying to create a Video Component, that will look like Image component(just drag and drop the asset).

This is how I build the dialog:

<video jcr:primaryType="nt:unstructured" sling:resourceType="cq/gui/components/authoring/dialog/fileupload" autoStart="{Boolean}false" class="cq-droptarget" fieldLabel="Image asset" fileNameParameter="./fileName" fileReferenceParameter="./fileReference" mimeTypes="[video/quicktime]" multiple="{Boolean}false" name="./video" title="Upload Image Asset" uploadUrl="${suffix.path}" useHTML5="{Boolean}true"/>

But, I can not return the path from the java model.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

@lukasz-m 

@Model(
        adaptables = {SlingHttpServletRequest.class},
        adapters = {VideoComp.class},
        resourceType = {ResourceType.Constants.VIDEO_COMP},
        defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)

@Slf4j
public class VideoCompImpl implements VideoComp {

    @Inject
    Resource componentResource;
    
    @OSGiService
    private ModelFactory modelFactory;

    @Self
    private SlingHttpServletRequest request;

    @ValueMapValue(name = "fileReference") 
    private String video;


    @Override
    public boolean isEmpty() {
        return false;
    }


    @Override
    public String getVideo() {
        return video;
    }


    
}

@ad-engineerCan you try this:

Remove ValueMapValue annotation and add below method

@PostConstruct
protected void initModel() {
   video = componentResource.getValueMap().get("fileReference", String.class);
}

2 replies

Kiran_Vedantam
Community Advisor
Community Advisor
October 6, 2021

Hi @ad-engineer 

 

Can you try the dailog field as a path field rather than the fileupload?

 

Thanks,
Kiran Vedantam

Level 3
October 6, 2021

It should be file upload

Sanjay_Bangar
Community Advisor
Community Advisor
October 6, 2021

Hi @ad-engineer ,

           You need to used filereference in sling model to access the path of video.

 

Regards,

Sanjay

Level 3
October 6, 2021

@sanjay_bangar yes but how?

this is my method:

 public String getVideo() {
        return video;
    }

It is not returning anything

lukasz-m
Community Advisor
Community Advisor
October 6, 2021

Hi @ad-engineer, could you please share part of code responsible for video variable initialization,. How video value is set in you sling model?