Display contents of a URL

28 Jun '13, 01:04 AM
29,988 Views
Forum Forum Starter - Level 2

Hi, I have a database table that has a field in it containing a URL. Is there any way to display a query result (sub-set of URLs) and show a list with a panel displaying a type of "preview" of the linked page, or as an image (similar to Facebook when you link to another page in news feed)?

The list of "preview" panels should also be able to display another field from the same table with a text description of the linked page. Cheers

 
x 0
Follow
Answer Answer at this question and get points!
No Forum Badges

Hi,

regarding your questions:

1) The <td class="<wr:StyleClass/> value...."> refers the code already available in the default template of the unit. Here, in the part of the code that manages the attributes, you have to add the code that prints the image. For example, this is the complete code:

<wr:Iterate var="attr" context="unit" select="layout:Attribute"> // at line 155
  <wr:Visible position="'index'">
   [% if (showAttributeName == "true") {%]
     .....
   [% } %]
   [% if ((linkPosition == "on_row") && (!links.empty)) {%]
    .....
    <wr:Value/>
    .....
   [% } else {%]  // with the default Layout Parameters, the "else" part is executed
    <!-- not linked attribute -->
    <td class="<wr:StyleClass/> value<c:if test="${<wr:UnitId/>.currentIndex eq index}">Current</c:if>[% if (useAlternate == "true") { %]<c:if test="${index mod 2 eq 0}">Alternate</c:if>[% } %] [%=attr["type"]%]">  // the code part of your question                
        <wr:Value/>  // prints the link as a text
    </td>
   [% } %]
 </wr:Visible>
</wr:Iterate>

2) Can you write the part of the customized code that returns the error ? The "context" attribute should not be required.

   
x 1
No Forum Badges

Hi,

to show a list of data in the page (in your case of URLs) you can use an Index Unit. To filter the list you can add a condition (e.g. right click on the Index Unit > Add > Attribute Condition).

For displaying a link as an image you can for example customize the template of the unit and add the code that prints the image. For example, in case of the Index Unit:

....
<wr:Iterate var="attr" context="unit" select="layout:Attribute">
.....
<td class="<wr:StyleClass/> value....">
 <a target="_blank" class=" " href="<c:out value="${current.url}"/>">
   <img src="<path>" title="<c:out value="${current.url}"/>"/>
 </a> // prints the link as an image
 <wr:Value/> // prints the link as a text
</td>
.....
.....
</wr:Iterate>

where "url" is the attribute with the URL and "<path>" is the path of the image relative to the Style Project (e.g. Images/link.png). If you wish to display a different image for each link: Images/${current.name}.png, where "current.name" refers the "name" field in the database containing the name of the image, such as Facebook.

This is a sample result page:

alt text

To display a panel with a text description you can for example model a tooltip on the link. In this case, you can refer this tutorial: Help > Web Modeling Tutorials > The AJAX Tooltip

 
x 0
Forum Starter - Level 2

Hi Laura!

This question pertains to the Sensor Custom Unit that I described in this thread

Just recapping the important bit:

My research project is to create a generic design pattern to easily define and include Stigmergy into web pages. Ideally the implementation will be completely encapsulated in Custom Units. There are two types of Custom Units and they display one of two variations when they instantiate themselves:

- Actuator Custom Unit (instantiates as Marker Based or Sematectonic) creates the "trail" and
- Sensor Custom Unit (instantiates as Quantitative or Qualitative) displays the trail.

This question is only about the Sensor Custom Unit. It's a standard design Custom Unit with a service java class and a bean java class. It creates a record in the Contribution database table is two ways; one for Marker Based, one for Sematectonic.

NOTE : The Sensor can provide Quantitative output (number of "Likes" or "Seen By" or Qualitative output (similar to Facebook "Share" where it displays some linked content ... or Amazon "People who bought this also bought ...". Getting the Qualitative output is the issue I'm trying to solve for the Sensor Unit.

The Quantitative instantiation is working where a single text value is provided (E.g., "SELECT COUNT(*) WHERE ..." provides the number of "Likes"). This is easily displayed using:

<c:if test="${<wr:UnitId/>.isQuantitative}"> <tr class="row"> <td valign="middle" nowrap="nowrap" class=" value"> <c:out value="${<wr:UnitId/>.contributionOutput}"/> </td> </tr> </c:if>

If the instantiation is Qualitative, then the style unit it can offer one or more Urls (or text descriptions) where the java bean returns a map with an Oid/URL Map. So the WR:Iterator you describe really needs to be replaced with something like:

<c:if test="${!<wr:UnitId/>.isQuantitative}"> <th valign="middle" class=" header"> <c:out value="${<wr:UnitId/>.signOutputLabel}"/> </th> <c:forEach var="contribution" items="${<wr:UnitId/>.contributions}"> <td class="<wr:StyleClass/> value...."> <a target="_blank" class=" " href="<c:out value="${contribution.value}"/>"> <img src="<path>" title="<c:out value="${contribution.value}"/>"/> </a> // prints the link as an image <wr:Value/> // prints the link as a text </td> </c:forEach> </c:if>

The Problem:

I haven't gotten this code working yet, but if you could suggest whether my "c:ForEach" will work at run-time the same as your suggested "wr:Iterate". From our previous discussion I thought that the "wr" tags resolved to groovy script equivalents and we established that these are processed at page generation time (not run-time)? In that case I anticipate that your suggested solution would not work for my example.

Secondly, I was hoping to get some kind of preview (like Facebook does for "Share" content as thumbnails) and wonder if there is a feature to do that?

Either way, getting the Custom Unit's Style Unit to be able to iterate through the Map as returned by the java bean (for the Custom Unit) is my primary goal. I'll work this weekend to try and get it compiled and returning a list this weekend, but if my approach is incorrect I'd love to hear that before I "lose" my weekend. ;p

Again, all help gratefully appreciated thank you!

 
x 0
Forum Starter - Level 2

Quick update :

I did get the code working using the Map iteration rather than the w:iterator. It needs a bit of formatting but each of the little ants are links off to the correct URL.

I suspect that to create the "preview" I will need to do it in Java in the Service, and open a stream to the URL into a graphics buffer and then render it out from memory into a jpg ... This therefore is outside the Web Ratio forum.

Alt text

So top points for your help, though 2 more questions:

Question 1: In your code <td class="<wr:StyleClass/> value...."> what do you put for the "value...."?

Question 2: I get a compile error for your line <wr:Value/>. The error states that a context is mandatory?

 
x 0
Forum Starter - Level 2

I see the issue now with the complete code listing (and this solves both question 1 and 2).

Regarding Question 1

Your example is still based on the Index Unit being modified, hence you have all the values available to you. E.g., showAttributeName, linkPosition, etc.

My Custom Unit returns a custom bean for the unit and is very rigid in what it returns and is written from a blank start. Now that I see the full code I see that the layout is different to what I will use because you provide the groovy conditional evaluation of how to display the layout.

Regarding Question 2

Your expanded example shows the <wr:Visible position='index'> tag which opens the tag. NOTE: the tag generating the context error being the closing of that tag. E.g., <wr:Visible/>

Thanks again for your help on this!

 
x 0
Answer at this question and get points!

Related questions

2 grids inside one/same cell result in non-selectable 2nd grid Access page variable in a page template add html Ajax is not working in own style project Ajax web app with javascript history object using the WebRatio Alimentar graficas con base de datos Alternate way to get current User Oid in layout template groovy script? Any way to localize the Tab Grid Template (Webratio Store)? Applicare un template ad un Web Project Ayuda Simple List Component Layout personalizado Bootstrap Style Button to go on another page Cambiare dimensioni bottoni - Change button size Can I inject html into custom unit template?! Change color template bootstrap style Change Style Changing the login page does not work ckeditor - change directory for the browser Colore Attributi index unit Dinamico - Index unit dynamic attribute color Como abrir una ventana en ajax desde una master page Como embeber un video subido desde archivo ? Como mostrar una imagen de portada arriba del menu? Como mostrar una imagen en una lista o en la componente detalles? Confirm Dialog Customize layout mobile platform Custom Tooltip Position Default error pages default login page Dynamic link labelling for Custom Unit Error in Excel Unit - Font size Export to a HTML/CSS/JS project Field as link soruce File CSS non considerato in generazione Form element Form template Get date pattern Get home page from template Google map is not shown properly in the tab grid Guardar Saltos de LINEA HelloWorld Unit sample code Hiding landmarks (or flows) when the user is logged in How can i create pagemenu or landmarkmenu with multiple levels. How can I modified the htmls files to perform my style How to add an image in a modal/pop-up window? How to include a template into other template? How to localize AJAX waiting dialog? How to localize the multi message unit in the notification layout How to modify template? How to modify the FertileEnviroment Default page How to remove default Linked Resources? How to use LandmarkMenu as AJAX navigation how to use the landmark menu as AJAX navigation integrate framework to webratio mobile Integrazione javascript Javascript and html javascript history object Localize "Welcome..." and "Process details" logo webratio meaning of each tag in the XML code (Show XML/Show Layout XML) modify field html Modify html generated by wr:NavigationBar Pages Problem After Project Generation pass template variable Problem Login Form only if user not logged Problem print Problems with the page refresh (Tab Grid) Problem with adding templates query unit who to hide fields that are used in a link Recursive Hierarchical Index Unit Style Tree Redirect to the default module Remove default BPM css import for all templates Responsive Bootstrap Grid Responsive Layout Manager Set context parameter Simple Static Page Standard confirm dialog replacement Style hierarchical unit help!! Supoort for Mobile and Desktop display Target tabs in Tab Grid Control Tooltip on a field Too much layout parameters = no scroll in parameters config window Uppercase Use image as interaction flow Vista de diferentes Site Views Webratio Add-ons no permite login wr-ajaxDivs break layout on ajax pages.