Your are missing the relId and the relationship.
If you create a sample pptx and upload it at
http://webapp.docx4java.org/OnlineDemo/PartsList.html you'll see in your slide part, a txBody like:
Using xml Syntax Highlighting
<p:txBody>
<a:bodyPr/>
<a:lstStyle/>
<a:p>
<a:r>
<a:rPr lang="en-US" dirty="false">
<a:hlinkClick r:id="rId2"/>
</a:rPr>
<a:t>https://www.docx4java.org/trac/docx4j
</a:t>
</a:r>
<a:endParaRPr lang="en-US" dirty="false"/>
</a:p>
</p:txBody>
Parsed in 0.001 seconds, using
GeSHi 1.0.8.4
There you can generate the following code:
Using java Syntax Highlighting
org.
docx4j.
dml.
ObjectFactory dmlObjectFactory
= new org.
docx4j.
dml.
ObjectFactory();
CTTextBody textbody
= dmlObjectFactory.
createCTTextBody();
// Create object for p
CTTextParagraph textparagraph
= dmlObjectFactory.
createCTTextParagraph();
textbody.
getP().
add( textparagraph
);
// Create object for endParaRPr
CTRegularTextRun regulartextrun
= dmlObjectFactory.
createCTRegularTextRun();
textparagraph.
getEGTextRun().
add( regulartextrun
);
// Create object for rPr
CTTextCharacterProperties textcharacterproperties
= dmlObjectFactory.
createCTTextCharacterProperties();
regulartextrun.
setRPr(textcharacterproperties
);
textcharacterproperties.
setLang( "en-US");
// Create object for hlinkClick
CTHyperlink hyperlink
= dmlObjectFactory.
createCTHyperlink();
textcharacterproperties.
setHlinkClick(hyperlink
);
hyperlink.
setAction( "");
hyperlink.
setTgtFrame( "");
hyperlink.
setTooltip( "");
hyperlink.
setInvalidUrl( "");
hyperlink.
setId( "rId2");
textcharacterproperties.
setSmtId( new Long(0
) );
regulartextrun.
setT( "https://www.docx4java.org/trac/docx4j");
// Create object for endParaRPr
CTTextCharacterProperties textcharacterproperties2
= dmlObjectFactory.
createCTTextCharacterProperties();
textparagraph.
setEndParaRPr(textcharacterproperties2
);
textcharacterproperties2.
setLang( "en-US");
textcharacterproperties2.
setSmtId( new Long(0
) );
// Create object for bodyPr
CTTextBodyProperties textbodyproperties
= dmlObjectFactory.
createCTTextBodyProperties();
textbody.
setBodyPr(textbodyproperties
);
// Create object for lstStyle
CTTextListStyle textliststyle
= dmlObjectFactory.
createCTTextListStyle();
textbody.
setLstStyle(textliststyle
);
Parsed in 0.020 seconds, using
GeSHi 1.0.8.4
The slide rels part (not shown by the webapp) contains:
Using java Syntax Highlighting
<Relationship Id
="rId2" Type
="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target
="https://www.docx4java.org/trac/docx4j" TargetMode
="External"/>
Parsed in 0.014 seconds, using
GeSHi 1.0.8.4
To add the hyperlink rel, try something like (untested):
Using java Syntax Highlighting
org.
docx4j.
relationships.
ObjectFactory factory
=
new org.
docx4j.
relationships.
ObjectFactory();
org.
docx4j.
relationships.
Relationship rel
= factory.
createRelationship();
rel.
setType( Namespaces.
HYPERLINK );
rel.
setTarget(url
);
rel.
setTargetMode("External");
slidepart.
getRelationshipsPart().
addRelationship(rel
);
Parsed in 0.015 seconds, using
GeSHi 1.0.8.4
then in your slide, its hyperlink.setId( rel.getId() )