Jsp div order get changed while rendering - java

In jsp div's are in below order
<div id="identification"/>
<div id="address"/>
<div id="communication"/>
<div id="familyDetail"/>
but while rendering in JBOSS and Weblogic server below is HTML output
<div id="address"/>
<div id="communication"/>
<div id="identification"/>
<div id="familyDetail"/>
Jsp java file also in same order as in jsp but while converting in HTML it gets changed

Related

Get first level element of HTML document - Java

I want to get the first level elements of the HTML tag <wicket:extend> in below document. I am using Jericho API for html parsing but didn't find any method/way to get the first level elements.
<body>
<wicket:extend>
<div wicket:id="container1"> some elements</div>
<div wicket:id="container2">
<h2>This is container 2</h2>
</div>
<div wicket:id="container3">
<h2>This is container 3</h2>
</div>
<div id="panel2">
<h2>This is panel2</h2>
</div>
<h3>This is heading3</h3>
</wicket:extend>
Expected output
<div wicket:id="container1">
<div wicket:id="container2">
<div wicket:id="container3">
<div id="panel2">
<h3>This is heading3</h3>

Wicket : render/refresh RepeatingView without having html tag

So i have FormControl inside Repeating View and i set html for Repeating view as Wicket:container
I am trying to refresh formControl but because i am stripping wicket tags in output
it gives JS error.
i know wicket:container can not be refreshed. but i am not able to refresh control inside it. I tried setting
control.setOutputMarkupPlaceholderTag(true);
control.setOutputMarkupId(true);
And Html is Something like this
<form wicket:id="form">
<wicket:container wicket:id="repeatingContainer">
</wicket:container>
</form>
here is error i am getting
Cannot bind a listener for event "change" on element "id1a3" because the element is not in the DOM
i want to remove repeatingContainer html tag from output so it follows bootstrap form layout.
Update:
This code is inside the RepeaterView
<wicket:panel>
<div wicket:id="componentGroup">
<wicket:child/>
</div>
</wicket:panel>
This code wicket Child
<div wicket:id="labelContainer">
<label wicket:id="label"></label>
</div>
<div wicket:id="controlContainer" class="control-container">
<input wicket:id="input"/>
</div>
ok so i am able to tackle this down.
I updated component Group div to wicket:container and leave the Repeater as div. So now i am able to refresh. and it works alright.
So this is how it will look like
<form wicket:id="form">
<div wicket:id="repeatingContainer">
<wicket:container wicket:id="componentGroup">
<div wicket:id="labelContainer">
<label wicket:id="label"></label>
</div>
<div wicket:id="controlContainer" class="control-container">
<input wicket:id="input"/>
</div>
</wicket:container>
</div>
</form>

get parameter in servlet for for each loop

I have a jsp page like this
<c:forEach var="product" items="${products}" >
<div class="col-md-3">
<div class="panel-body">
<div>
<a href="description.html">
<div class="thumbnail">
<img src="data:image/jpeg;base64,${product.base64EncodedImage}" alt="image">
<div class="caption" align="center">
<p>
<h4>${product.name}</h4>
<h5>cost:Rs ${product.price}/-</h5>
i fetch the productimage,price,name using for each.from for each in jsp i have to get parameter values in servlet using request.getParameter() and have to implement in another page using those parameters
I have a tumbnails in page.when we click on it it redirects into another page.there we have to set particular tumnails image,product name,price
help me how to get that parameters in servlet class
please check image in this link--->>
I have to get the Product name,product price, image from 1 tumbnail
Thanks !
Provide hyperlink on image and send all the details you want on servlet as query string
<a href="ServletName?name=${product.name}&price=${product.price}">
<img src="data:image/jpeg;base64,${product.base64EncodedImage}" alt="image"/>
</a>
OR
Send only product id and in servlet fetch all product details for that id from database
<a href="ServletName?id=${product.id}">
<img src="data:image/jpeg;base64,${product.base64EncodedImage}" alt="image"/>
</a>

Display a string that contains HTML in Thymeleaf template

How can I display a string that contains HTML tags in Thymeleaf?
So this piece of code:
<div th:each="content : ${cmsContent}">
<div class="panel-body" sec:authorize="hasRole('ROLE_ADMIN')">
<div th:switch="${content.reference}">
<div th:case="'home.admin'">
<p th:text="${content.text}"></p>
</div>
</div>
</div>
//More code....
And at this line of piece of code ${content.text} it literally generates this on the browser:
<p>test</p>
But I want to show this instead on the browser:
test
You can use th:utext (unescaped text) for such scenarios.
Simply change
<p th:text="${content.text}"></p>
to
<p th:utext="${content.text}"></p>
I will suggest to also have a look into documentation here to know all about using Thymeleaf.

How to invoke a div from another jsp

I have a jsp with multiple divs and another jsp with links to these divs. I would like to invoke a specific div on the click of a link.
First JSP
<html>
<li>
What is 'porting'?
</li>
</html>
legals.jsp(Second jsp)
<div id="tab-01" class="ta-body" role="tabpanel" tabindex="0">
<h4>What is 'porting'?</h4>
<p>
Porting is....
</p>
</div>
In the First JSP, change href="legals.jsp"attribute to this:
href="legals.jsp#tab-01"

Categories