I have list of articles in html.In every article i have multiple image tags like added below
<img alt="quick-start" class="alignnone size-full wp-image-16745" height="224" sizes="(max-width: 474px) 100vw, 474px" src="http://localhost/myfolder/my-content/uploads/2016/11/Quick-start.jpg" srcset="http://localhost/myfolder/my-content/uploads/2016/11/Quick-start.jpg 474w, http://localhost/myfolder/my-content/uploads/2016/11/Quick-start-300x142.jpg 300w" style="box-sizing: border-box; margin-top: 10px; margin-bottom: 10px;" width="474" />
Problem Statement:
I want to replace urls of image present in src, srcset i-e http://localhost/myfolder/my-content/uploads/2016/11/Quick-start.jpg to some other url.
whats the best approach to do that. I am thinking about functional programming in java
Yes this can be done using java.But it will be easy if you manipulate using java script framework like jquery.
$(".image2").attr("src","image1.jpg");
Related
I'm starting work on a little HTML5 canvas game, and I was thinking GWT would be a great idea. I'd like to use Java, because 1. I have a lot of experience with it and 2. I would like to do it in an OO language. However, I read something about it being a pain to manage the HTML and CSS through GWT. So I was wondering, could I set up the canvas and style it using plain HTML+CSS, but then do everything else in GWT?
You don't need to use GWT to generate HTML or CSS.
I mostly use GWT with Ui:Binder, where the top-level element is HTMLPanel. Inside it, as much as possible is plain HTML and CSS. I try to keep project-level CSS in an outside .css file to ensure consistency, but you can pull as much CSS as necessary inside the Ui:Binder template.
Example of a Ui:Binder template, where I mix widgets (HTMLPanel, FlowPanel) with pure HTML. I use GWT widgets when I need some convenient functionality that they already provide, but you can deal with them as elements as well.
<ui:style>
.empty {
width: 100%;
line-height: 96px;
font-size: 16px;
text-align: center;
}
</ui:style>
<g:HTMLPanel>
<h2 class="sides">My Favorites</h2>
<div ui:field="emptyLabel" class="{style.empty}" >You have no favorites at this time.</>
<g:FlowPanel ui:field="container" addStyleNames="row flex-wrap" />
</g:HTMLPanel>
-
hey folks,
i am building a Java-tool, trying to automatically fill out some form input elements in an HTML-Page using Java and Jaunt API.
the HTML-Code is like:
<fieldset class = "fieldsetlong">
<legend>searchprofile</legend>
<label for="reference">reference:</label>
<input maxlength="50" name="reference" id="reference" type="text" />
</fieldset>
<fieldset class = "fieldsetlong">
<legend>searchcriteria</legend>
<label for="surname">surname:</label>
<input name="searchprofile.surname" id="surname" type="text" />
</fieldset>
The Java-Code for filling in the "normal" Input-field reference (it works) looks like:
form.set("reference", "123Test");
Unfortunately, I am not able to fill out the fields that use the dot-notation searchprofile.surname in the name
Here's a sample of what i've tried (without success):
form.set("surname", "TestPerson");
form.set("searchprofile.surname", "TestPerson");
form.set("name=\"searchprofile.surname\"", pers.getSurname());
form.set("id=\"surname\"", pers.getSurname());
For each of these commands I get a NotFoundException and don't know whether I can do this with Jaunt.
It would appreciate any kind of help in this regard.
Thanks in advance
Edit - is there a way to reach the dot-notated input-field searchprofile.surname with JSoup?
HTML allows dots in the name-Attribute, but does Jaunt accept this abc.name?
Not sure about Jaunt, never used it before. However Jsoup seems to be a pretty decent library to be used here. I myself have been using Jsoup for a fairly long time and it has been very successful in scraping web pages, filling input form and submit, and of course, HTML parsing!
I've posted a step by step guide to fill in form input fields and submit to server in the following answer: How to login with Jsoup
Basically it works very similar to your code, a very brief example would be:
Connection.Response response = Jsoup.connect(url)
.data("Name", "Value")
.method(Method.POST).execute();
Today, at work the Jaunt solution with
form.set("searchprofile.surname", "TestPerson");
worked like a charm.
I don't know what the problem was earlier but I am glad that it worked.
The HTML allows to use dots and minus, etc. which I misinterpreted as some kind of nested forms or hierarchies but the dot-notation is just a valid name-attribute in HTML.
Im new at vaadin 7 and have a little issue with formatting.
I have spend a few hours but no luck.
I have:
2 Form layouts on my vertical Layout.
2 Labels on each form layout.
Better check the screenshot
I want format label test as on the right part of screenshot.
Can you please advice or share thoughts or ideas.
I'm not 100% certain if I get what you're trying to do, but you might be able to achieve this through custom CSS.
It is hard to write out the exact CSS since it would require seeing the HTML generated by Vaadin and testing it with that, but it would be something like this for the labels:
.padded-form-layout v-caption:first-child {
float: left;
padding-left: 30px; /* set desired padding used for each label */
}
Of course, you'll need something similar for the values as well.
Above, padded-form-layout is the class name you define for layouts that need this look. In Java:
formLayout.setStyleName("padded-form-layout");
To figure out what the CSS modifications needed are I recommend you open the page in browser (Chrome or Firefox will do) and use the dev tools to directly modify the CSS to figure out what rules are needed. I usually do this by simply typing a style tag to the element, something like this (in this example, style="XXXXX" would be added manually. This is possible at least with Chrome's developer tools):
<div class="v-formlayout v-layout v-widget v-has-width" style="width: 100%;">
<!-- ... -->
<td class="v-formlayout-captioncell">
<div class="v-caption v-caption-hasdescription">
<span id="gwt-uid-21" for="gwt-uid-22" style="XXXXX">First name:</span>
<span class="v-required-field-indicator" aria-hidden="true">*</span>
</div>
</td>
<!-- ... -->
</div>
To be able to use the CSS, you'll need to either add it to your theme somehow and compile it (see Vaadin documentation about themes), or by using the #StyleSheet annotation
I'm trying to generate a custom map for a web application based on portlets, for what I've seen so far, google maps offers and i frame which takes some coordinates and draws them on the map. I want to do it according to some variables i have stored but i cna't manage to include them in the href nor in the iframe it just prints the whole reference to the variable i.e #{EntregaListaBean.entregaActual.longitud}.
Does anybody know what's my error? what can i do to generate it dynamically?
here's a piece of code that does work and uses the values stored:
<h:outputLabel value="Etapa actual" id="ol3"
style="font-weight:bold;"/>
<h:outputText value="#{EntregaListaBean.entregaActual.etapa}" id="ot4"/>
And heres a code that simply doesnt work:
Ver posicion actual
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?q=# {EntregaListaBean.entregaActual.latitud},#{EntregaListaBean.entregaActual.longitud}&ie=UTF8&t=w&z=14&ll=#{EntregaListaBean.entregaActual.latitud},-#{EntregaListaBean.entregaActual.longitud}&output=embed"></iframe><br /><small>View Larger Map</small>
you can use the
<af:inlineFrame>
tag, it renders an iframe and you can use EL like your example.
I'm trying to adapt the code used in PSI Probe (or more generally, the idea of PSI Probe) to be used inside of my company's web application. I can get the majority of the portions of what I'm looking to do, but I have become stuck on one bit of code - the 'Status' tab. One column of data is the processing time for the thread, data I would really like to have, but I can't figure out where it is coming from. Here's the relevant snippet:
<c:forEach items="${pools}" var="pool" varStatus="poolStatus">
<div class="poolInfo">
<h3>${pool.name}</h3>
<div class="processorInfo">
<span class="name">
<spring:message code="probe.jsp.status.processor.maxTime"/>
</span>
${pool.maxTime}
I can't figure out where the pools object is coming from! Does anyone have experience with this sort of thing? Thanks!
Looking at the source code (this being Google code, a Google search works really quick)
the pools is being populated in the ListThreadPoolsController
List pools = containerListenerBean.getThreadPools();
return new ModelAndView(getViewName())
.addObject("pools", pools);
A closer look at ContainerListenerBean
shows the properties which are listed in status.jsp
<span class="name"><spring:message code="probe.jsp.status.currentThreadCount"/></span> ${pool.currentThreadCount}
<span class="name"><spring:message code="probe.jsp.status.currentThreadsBusy"/></span> ${pool.currentThreadsBusy}
<span class="name"><spring:message code="probe.jsp.status.maxThreads"/></span> ${pool.maxThreads}
<span class="name"><spring:message code="probe.jsp.status.maxSpareThreads"/></span> ${pool.maxSpareThreads}
<span class="name"><spring:message code="probe.jsp.status.minSpareThreads"/></span> ${pool.minSpareThreads}
are being populated in the getThreadPools() method
ThreadPool threadPool = new ThreadPool();
threadPool.setName(executorName.getKeyProperty("name"));
threadPool.setMaxThreads(JmxTools.getIntAttr(server, executorName, "maxThreads"));
threadPool.setMaxSpareThreads(JmxTools.getIntAttr(server, executorName, "largestPoolSize"));
threadPool.setMinSpareThreads(JmxTools.getIntAttr(server, executorName, "minSpareThreads"));
threadPool.setCurrentThreadsBusy(JmxTools.getIntAttr(server, executorName, "activeCount"));
threadPool.setCurrentThreadCount(JmxTools.getIntAttr(server, executorName, "poolSize"));
It can come from two places, generally. A Servlet that is invoked before the JSP or a Filter. Check all filters, and the servlet mapped to the url you are opening.