Unable to display HTML content in Wicket

Consider the following HTML structure:

<div class="pull-right">
    <div class="btn-group">
        <a href="#" class="btn btn-default">
            <i class="ico ico-prev"></i>
        </a>
        <div class="dropdown2 inline">
        <a href="#" class="btn btn-default btn-shorter">
            <strong>1-8</strong>
        </a>
        <ul class="dropdown-menu spec_width">
            <li><a data-ico="1" href="#">10-30</a></li>
            <li><a href="#">30-40</a></li>
            <li><a href="#">40-50</a></li>
            <li><a href="#">50-60</a></li>
        </ul>
    </div>
    <a href="#" class="btn btn-default">
        <i class="ico ico-next"></i>
    </a>
</div>
<span class="page-title">from<strong>45</strong></span>

.dropdown-menu {
    padding: 0;
    margin: 0;
    left: -1px;
    top: 37px;
    font-size: 13px;
    -webkit-box-shadow: 0px 0px 25px 0px rgba(100, 100, 100, 0.5);
    -moz-box-shadow: 0px 0px 25px 0px rgba(100, 100, 100, 0.5);
    box-shadow: 0px 0px 25px 0px rgba(100, 100, 100, 0.5);
    border: 1px solid #d1d4d3;
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    border-radius: 0;
    background-color: #f9f9f9;
}
.dropdown-menu li > a {
    color: #4d5357;
    padding: 8px 20px;
}
.spec_width {
    width: 72px;
    min-width: 72px;
    left: 50% !important;
    margin-left: -36px;
    max-height: 150px;
    min-height: 30px;
    float: left;
    overflow: hidden;
    display: block !important;
    visibility: hidden;
}
.spec_width li {
    line-height: 29px;
    width: 100%;
    text-align: center;
padding: 4px 0;
}

.spec_width li:hover {
    background: #e1e1e1;
}

.spec_width li a {
    padding: 0px 0;
    background: none !important;
    width: 100%;
    text-align: center;
}

I incorporated this markup in ModalWindow and it performed well. However, I encountered an issue when adding a CSS class to the <ul> tag. Despite generating in the HTML code upon inspection, it doesn't appear in the browser. This discrepancy could be attributed to potential conflicts with scripts or styles due to its implementation in a ModalWindow. Any thoughts on how to resolve this?

Answer №1

If you're looking to utilize Wicket for creating HTML emails, a workaround is needed to simulate the request/response cycle. I've crafted a handy method that can render a bookmarkable page (pageclass + pageparameters) into a string:

Here's an example of how this method operates:

// Access the servlet context
  WebApplication application = (WebApplication) WebApplication.get();

// Simulate a fake request/response cycle
  MockHttpSession servletSession = new MockHttpSession(context);
  servletSession.setTemporary(true);

  MockHttpServletRequest servletRequest = new MockHttpServletRequest(application, servletSession, context);
  MockHttpServletResponse servletResponse = new MockHttpServletResponse(servletRequest);

  // Initialize request and response
  servletRequest.initialize();
  servletResponse.initialize();

  WebRequest webRequest = new WebRequest(servletRequest);

  BufferedWebResponse webResponse = new BufferedWebResponse(servletResponse);
  webResponse.setAjax(true);

  WebRequestCycle requestCycle = new WebRequestCycle(application, webRequest, webResponse);
  requestCycle.setRequestTarget(new BookmarkablePageRequestTarget(pageClass, pageParameters));

  try {
     requestCycle.request();
     
     log.warn("Response after request: " + webResponse.toString());

     if (requestCycle.wasHandled() == false) {
         requestCycle.setRequestTarget(new WebErrorCode ResponseTarget(HttpServletResponse.SC_NOT_FOUND));
     }

     requestCycle.detach();
  } finally {
     requestCycle.getResponse().close();
  }
  
  return webResponse.toString();

Answer №2

By adding

target.appendJavaScript("launchJS();");
to my code that already contained AjaxRequestTarget, I successfully resolved the issue at hand.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating square images in CSS without specifying their dimensions can easily be done by centering

Is there a way to create square images from rectangular ones in CSS, while ensuring they remain centered on the page? I have come across numerous solutions that use fixed pixel sizes, but I need my images to be responsive and set in percentages. Essential ...

Invoking the callback function within the containing scope in Typescript

I am facing an issue with my Angular component where I have a class that includes common services and functions. While passing some functions as callbacks, the scope is getting lost during execution. Let me demonstrate the problem through the code below: @ ...

Issue: Dependency type ContextElementDependency does not have a corresponding module factory available

After cloning the project from GitLab and running npm install, all dependencies were successfully downloaded. However, upon executing npm start, I encountered an error stating "No module factory available for dependency type: ContextElementDependency." In ...

Enhance the graph with additional information through the use of a variable

I've been experimenting with charts using this plugin, and now I'm trying to figure out how to add data to the graph using a JSON string: Morris.Line({ element: 'line-example', data: [ { y: '2006', a: 100, b: 90 }, ...

Attempting to get Masonry-Layout functioning properly in Safari using imagesLoaded

I recently set up a Masonry Gallery for a WordPress site using Bootstrap 5 with 'Masonry-Layout'. Everything was working perfectly, except in Safari where the layout kept breaking. I know the solution is supposed to be 'imagesLoaded', b ...

Implement the useState setter functionality within a child component

I need help figuring out how to properly type a useState setter that I'm trying to pass to a child component. const Parent = () => { const [count, setCount] = useState(0); return( Child count={count} setCount={setCount} /> ); } W ...

Create a header for an HTML table

I need to style the header table with color based on a specific HTML structure. However, my CSS code doesn't seem to be working: <table class="dgrid" rules="all" id="Gridview2" style="border-collapse: collapse;" cellspacing="0" border="1"> ...

Checking Dates with Calendar Extender and JavaScript in ASP.NET

Is it possible to utilize JavaScript in order to prevent selection of Saturdays and Sundays on my Calendar Extender? At present, I am disabling previous dates using code-behind during page load. public partial class TESTING : System.Web.UI.Page { pro ...

After running the command "npx/npm create-react-app hello" to create a react app, I received the following message

Whenever I try to execute this command for creating a React app: C:\WINDOWS\system32> npm i create-react-app -g hello I receive the following message in my cmd prompt: npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf ...

Reformat the date retrieved from Json

When the date is retrieved from the Json data, it is displayed as follows: 2017-09-14T22:11:05.5303556 Is there a way to present it in a more user-friendly format, such as: 09/14/2017 22:11:05 Here is a snippet of the Json data: [ { id: 98, dateCreate ...

Ensure the beginning and ending times are accurate for newly added input fields using jQuery

I've included a JSFIDDLE link here for reference. The validation for start and end time kicks in when the 'Next' button is clicked, located on the same page. I'm looking to validate the start and end times for dynamically generated fiel ...

Achieving vertical alignment of footer contents using CSS

https://i.sstatic.net/0qVgh.png This image illustrates my issue. I am attempting to align both the copyright text and my Font Awesome icons vertically. Below is my HTML code: <footer> <p>Copyright &copy; 2016 Sample SIte</p> <di ...

Connecting JSON objects based on unique GUID values generated

I am in search of a method to automate the laborious task of linking multiple JSON objects with random GUIDs. The JSON files are all interconnected: { "name": "some.interesting.name", "description": "helpful desc ...

Dynamic styling based on conditions in Next.js

After a lengthy hiatus, I'm diving back in and feeling somewhat disconnected. In short, I have encountered a minor challenge. I successfully created a navigation menu pop-out that toggles classname based on the isActive condition in React. However, I& ...

Adjusting Font Size of Menu BarORModifying

I'm currently using WordPress to build my website. If you'd like to take a look, here is the link: I'm trying to make the font size smaller to accommodate more menu bars on the site. Any suggestions on how I can achieve this would be great ...

The constructor for MappedByteBuffer in Android Studio is malfunctioning (super constructor malfunctioning)

I am facing an issue where I need to convert a byte array into a MappedByteBuffer. However, while attempting to create the MappedByteBuffer, I encounter an error message. error: cannot find symbol method MappedByteBuffer(int,int,int,int,byte[],int) In M ...

What could be the reason for the reduce function displaying the count of elements in an array?

Currently, I am diving into ES6 concepts through a tutorial. During my coding practice session, I stumbled upon something that is puzzling me. In the code snippet provided below, it displays '3' as an output. var primaryColors = [ { color: &a ...

Taking on The Notch: How Can I Improve?

I'm currently working on a website for my friend's bar, but I'm facing an issue with Chrome where the content can't push past the "notch". Interestingly, Safari displays it fine on mobile, while Chrome has this unsightly white space. I ...

Resizing the parent container when the height of its absolutely positioned children is unknown and dynamic upon window resize

https://codepen.io/umbriel/pen/MxazRE One interesting feature of my slideshow is that users can change the slide by swiping their mouse cursor horizontally over the slide container. Since the children (slides) are absolutely positioned, I faced a challen ...

Unsupported MIME format

I'm encountering an issue where my stylesheet is not applying to my handlebars. It was working fine yesterday, but today I'm seeing a MIME error and I'm unsure of the reason behind it. Any assistance would be greatly appreciated. Server Cod ...