EduGarage Logo
Search:
Site Map
Upcoming Events:
Please e-mail us if you would like your webinar, conference, or get-together to be featured in this space.
Stay Informed:

Building block to create pre-populated web-link

rated by 0 users
Not Answered This post has 0 verified answers | 2 Replies | 1 Follower

Top 200 Contributor
Male
4 Posts
Jeff Scissom posted on 6 Jul 2012 1:36 PM

Hi All,

I'm new to custom building blocks, but have gotten a decent amount of examples to work with. I'm trying to create a building block that, in essence, creates a web-link exactly like the built in function does, but has a prepopulated URL. The URL is "../courseID/term". 

Now, my problem is that I can get the building block to create the item using the following class:

 

 

public class ContentCreator {
public static void createContent(String title, String inputHtml, String sCourseId, String sParentId) 
throws PersistenceException, ValidationException {

// retrieve the Db persistence manager from the persistence service
BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();

// create a course document and set all desired attributes
Content content = new Content();
content.setContentHandler("resource/x-bb-externallink");
content.setLaunchInNewWindow(true);
content.setTitle(title);
content.setUrl("http://www.google.com");

// set additional attributes
Id courseId = bbPm.generateId(Course.DATA_TYPE, sCourseId);
Id parentId = bbPm.generateId(Course.DATA_TYPE, sParentId);
content.setCourseId(courseId);
content.setParentId(parentId);

// retrieve content persister and persist the content item
ContentDbPersister persister = (ContentDbPersister) bbPm.getPersister(ContentDbPersister.TYPE);
persister.persist(content);

}

}

However, when the item is created, it isn't created as a weblink. It is just created as an item. If I click the radial menu> edit > make no changes > click submit, then it acts as a web-link. 
Any suggestions?
Thanks

 

 

 

All Replies

Top 10 Contributor
100 Posts

try this instead:

ExternalLink content = new ExternalLink();
content.setLaunchInNewWindow(true);
content.setTitle(title);
contnet.setUrl("http://www.google.com");

Top 200 Contributor
Male
4 Posts

Worked like a charm. Thanks!

 

Just in case anyone else tries this, I did also have to include blackboard.data.content.ExternalLink; at the top of the class.

Page 1 of 1 (3 items) | RSS
© 2006-2009 Blackboard Inc. All Rights Reserved. Blackboard, the Blackboard logo, and EduGarage are trademarks
or registered trademarks of Blackboard Inc. in the United States and/or other countries.