I have a temple like this:

<?xml version="1.0" encoding="UTF-8" ?>
<messages>
    <message id="x-template">
        <wt id='audio1' class='audio' type='audio/mpeg' width='640'
height='360' src='/resources/audio.mp3'></wt>
        ${audio1}
        <wt id='audio2' class='audio' type='audio/mpeg' width='640'
height='360' src='/resources/audio.mp3'></wt>
        ${audio2}
    </message>
</messages>

I want to iterate over the whole temple and look for all tags "wt",
then read in the type, so I can do a switch on type so I can use the
correct Wt Widget to render the content,
as such ~

private:  Wt::WWidget* myTag;
app->messageResourceBundle().use("\path\xTemplate", false);
videoTemplate = new Wt::WTemplate(Wt::WString::tr("x-template"), this);
for(std::vector<Wt::WWidget *>::const_iterator it =
videoTemplate->children().begin(); it !=
videoTemplate->children().end(); ++it)
{
        switch(*it.value_type("type"))
        {
            case "audio/mpeg":
                myTag = *it; // Grant you this assumes width, height is
assigned to its property, then adds src as an extended property
                videoTemplate->bindWidget(*it.value_type("id"),
WrapView(&VideoManImpl::GetAudioPlayer));
                *.it.remove(); // Remove the Element after you read it
in is Optional, more work since Browsers ignore unknown tags
                break;
        }
}
Wt::WWidget* VideoManImpl::GetAudioPlayer()
{
    WContainerWidget *result = new WContainerWidget();
    Wt::WAudio *audio = new Wt::WAudio(result);
    audio->addSource(Wt::WLink(myTag->src)); // Grant you this element
will have to be added
    audio->width(myTag->width()); // These elements need to be assigned
    audio->height(myTag->height());
    return result;
}

Children was empty, so this doesn't work, but the concept is what I am
talking about,
I want to have a way to bind to an element based on an XML tag (wt)
based on its properties for the type of element,
seems simple enough, but I can not figure out how to iterate over
WTemplate,
any help would be great, this is a great feature to add to WTemplate,
I just need to figure out how to write it so I can make a better
suggestion on how to implement it,
this feature would be very powerful for other Widgets, 
you could streamline how to implement them in the template, 
instead of in code, by making this part of messageResourceBundle or
WTemplate,
this would also fix any need to add html5 code to templates,
since this is my work around. 

Thanks
Jeff Flesher


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to