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

  • Home
  • SEARCH
  • 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 6682015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:39:25+00:00 2026-05-26T04:39:25+00:00

I am setting the data in model as: @RequestMapping(/forms/builder/) public void renderMethod1(Model model) {

  • 0

I am setting the data in model as:

@RequestMapping("/forms/builder/")
public void renderMethod1(Model model) {            
    SoyMapData x=new SoyMapData("class","menu horizontal right");
    model.addAttribute("pageTitles", x);        
}

Which is mapped to below function via Spring:

@Override
protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
    String renderedResponse = null;
    renderedResponse = compiledSoyTemplates.render(templateName, model, messageBundle);
}

Here I need to check if model is of type SoyMapData, if yes then set the type of model to SoyMapDataelse map.
How can I do this?

I have tried below approach its not working.

  • 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-26T04:39:26+00:00Added an answer on May 26, 2026 at 4:39 am

    You can do that with the instanceof operator:

    SoyMapData soyModel;
    if (model instanceof SoyMapData) {
        // It is, get a reference using that type
        soyModel = (SoyMapData)model;
    }
    

    …but if you need to do that, it suggests a problem with the encapsulation in the API design. Your render method shouldn’t need to know what kind of Map it’s receiving, that breaks encapsulation.

    There are many ways to solve that. One is by deriving a new interface from Map that allows render to do its job, and then using that interface rather than Map in the method signature. But that’s only one way.


    Update: Re your updated code, if I understand you correctly, you want to call compiledSoyTemplates.render with either a SoyDataModel argument or a Map argument depending on whether model is a SoyDataModel. (E.g., it’s an overloaded method and you want the compiler to know which one to use.) If so, then you just use the information I gave you above like this:

    @Override
    protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
            String renderedResponse = null;
            if (model instanceof SoyDataModel) {
                renderedResponse = compiledSoyTemplates.render(
                    templateName,
                    (SoyDataModel)model,
                    messageBundle
                );
            }
            else {
                renderedResponse = compiledSoyTemplates.render(
                    templateName,
                    model,
                    messageBundle
                );
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm setting up a data model in django using multiple-table inheritance (MTI) like this:
I am using the new ADO.NET Entity Data Model on a simple database. I
I am just starting to model the data for a new C# project, which
I'm making a new data entry through AJAX. It consists of the model data
When setting up a UITableView's data source, I'd be interested to get views on
The Setting: The program in question tries to post form data via an AJAX
I am currently setting the connection string for my linq to sql data context
I have an application which stores data to the persistent store by setting the
By default in windows application setting are saved in this directory: %USERPROFILE%\Local Settings\Application Data\<Company
i have problem to correctly bind data to WPF Chart. When i'm setting ItemsSource

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.