Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3438332
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:10:28+00:00 2026-05-18T08:10:28+00:00

The web designer has given me HTML which looks like: <div …. style=background: transparent

  • 0

The web designer has given me HTML which looks like:

<div .... style="background: transparent url(xxx.png) 170px center no-repeat">

Unfortunately the contents of the image xxx.png is generated by the software, so I have made it a WebResource and use the following strategy to generate the URL for the resource which I then embed in the style= attribute using a Wicket AttributeModifier.

// App initialization code
String resourceName = ....;
getSharedResources().add(resourceName, myWebResource);

// Creating the widget
String url = getServletContext().getContextPath()
    + "/resources/org.apache.wicket.Application/" + resourceName ;
String style = "background: transparent url(" + url + ") 170px center no-repeat";
div.add(new AttributeModifier("style", new Model<String>(style)));

This works fine when I test it locally using Eclipse, but :

  • When I install this in production, I want to have Apache as a proxy to Jetty such that the context root isn’t visible, i.e. Apache forwards a request of /foo onto Jetty as /context-root/foo.
  • In general, I don’t think this is very elegant. I’m sure I am duplicating Wicket code here?

I understand Wicket solves this problem of context-roots and Apache proxying by only using relative URLs. That would be the most elegant solution I suspect. But if I have e.g. a IndexedParamUrlCodingStrategy then the URL could be of arbitrary length and I don’t know how many .. to include to get back to /resources.

Edit: The current solution is to use absolute URLs as in my code example above, and in Apache (a) rewrite /context-root/* into /* (b) as before then ADD the context root to all requests (c) forward to Jetty. That way most URLs can be without the context root but some URLs (to my resources) can have the context root and it’s OK. But I don’t like this solution!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:10:29+00:00Added an answer on May 18, 2026 at 8:10 am

    If the code is called from inside a component (or page):

    urlFor(new ResourceReference("sharedResourceName"));
    

    or

    RequestCycle.get().urlFor(new ResourceReference("sharedResourceName"));
    

    Sample application below. I used a ByteArrayResource for simplicity, but any Resource subclass will do:

    WicketApplication.java

    package app1;
    
    import org.apache.wicket.protocol.http.WebApplication;
    import org.apache.wicket.request.target.coding.IndexedParamUrlCodingStrategy;
    import org.apache.wicket.resource.ByteArrayResource;
    
    public class WicketApplication extends WebApplication {
        @Override
        protected void init() {
            super.init();
            getSharedResources().add("testResource", new ByteArrayResource("text/plain", "This is a test".getBytes()));
            mount(new IndexedParamUrlCodingStrategy("home/very/deep/folder", getHomePage()));
        }
        public Class<HomePage> getHomePage() {
            return HomePage.class;
        }
    }
    

    HomePage.java

    package app1;
    
    import org.apache.wicket.PageParameters;
    import org.apache.wicket.ResourceReference;
    import org.apache.wicket.behavior.SimpleAttributeModifier;
    import org.apache.wicket.markup.html.basic.Label;
    import org.apache.wicket.markup.html.WebPage;
    
    public class HomePage extends WebPage {
        public HomePage(final PageParameters parameters) {
            CharSequence resourceHref = urlFor(new ResourceReference("testResource"));
            add(new Label("link", "Click me!")
                .add(new SimpleAttributeModifier("href", resourceHref)));
        }
    }
    

    HomePage.html

    <html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" >
        <body>
            <a wicket:id="link"></a>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the point of the auto-generated 'designer' files in ASP.NET MVC Web Apps? I'm
I am attempting to allow my web designers to use the metadata we have
I know this won't be a popular question, because a lot of web designers
I've got some rather complex forms, that need to be configured by web designers.
I am working on a web application that is designed to display a bunch
I'm actually developing a Web Service in Java using Axis 2. I designed my
We're not doing real web development. We get our HTMLs from our designers, and
Web applications that want to force a resource to be downloaded rather than directly
Web browsers are good as thin clients for web applications. But if the user
Web parts seem to be used extensively in Sharepoint related development, but examples of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.