Injection not working in postbacks (with two named parameters)

Splash Forums PrettyFaces Users Injection not working in postbacks (with two named parameters)

This topic contains 12 replies, has 3 voices, and was last updated by  Marcos Ivanechtchuk 3 years, 2 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #23939

    Marcos Ivanechtchuk
    Participant

    Weird. I’m not receiving injection in postbacks with the code below. Only in requests.

    THIS NOT WORK->

    pretty-config.xml

    
    	<url-mapping id="siteNews">
    		<pattern value="/site/news/#{siteNews.urlDate}/#{siteNoticia.urlTitle}"/>
    		<view-id value="/site/news.xhtml" />
    		<action>#{siteNews.open}</action>
    	</url-mapping>
    

    siteNews

    
    	private String urlDate;
    	private String urlTitle;
    	
    	(getters and setters)
    
    	public void open() {
    		Date date = new SimpleDateFormat("dd-MM-yyyy").parse(urlDate);
    		news = (News) dao.findByUrl(date, urlTitle);
    	}
    

    However, i change to use only with the id and worked:

    THIS WORK->

    pretty-config.xml

    
    	<url-mapping id="siteNews">
    		<pattern value="/site/news/#{siteNews.id}"/>
    		<view-id value="/site/news.xhtml" />
    		<action>#{siteNews.open}</action>
    	</url-mapping>
    

    siteNews

    
    	private Long id;
    
    	(getters and setters)
    
    	public void open() {
    		news = dao.findById(id);
    	}
    

    Someone?

    #23969

    The property urlTitle is defined in siteNews, but in your mapping you are using #{siteNoticia.urlTitle}. Could this be the problem?

    #23976

    Marcos Ivanechtchuk
    Participant

    Hey Christian, no, i posted incorrectly. It’s in fact siteNews, i made a translation, the original have parts in portuguese. Consider please as siteNews.

    As i said, the weird thing is that is not injecting in postbacks, only when i use one parameter with id. I was thinking in nice urls, that’s because i was trying to put the date and the news title as parameters.

    #23977

    Ah, ok, in this case the wrong bean name isn’t the cause of this.

    But actually I’ve no idea why this is happening. So you say if you sent a GET request to /site/news/foo/bar, then both properties are null when accessing them in #{siteNews.open}? Could you show the part of the page that is sending the postback?

    Or even better, could you try to reproduce this problem in a small sample app?

    #23992

    Hey Ivmarcos,

    I’m sorry you’re having trouble with this. As Christian said, if you could reproduce this problem in a small sample app, and upload it here, that would help us quickly find the root cause of the issue!

    Thanks very much!
    ~Lincoln

    #24036

    Marcos Ivanechtchuk
    Participant

    Guys,

    Perhaps an incompatibility with PrimeFaces? Attached.

    Thanks very much.

    #24037

    Marcos Ivanechtchuk
    Participant

    Oops, here it is. Change the zip to war file.

    Tested in Jboss AS 7.1.1-Final.

    Attachments:
    1. test.zip
    #24048

    Thanks Markos,

    One favor to ask.

    It would be simpler if you just uploaded a ZIP-file with the POM and Sources. Attaching a WAR file doesn’t actually demonstrate all that much without the ability to run in debug mode.

    Could you do this by any chance? Just Zip up the project folder.

    Thanks!
    ~Lincoln

    #24049

    I’m attempting to reverse engineer your WAR zipfile.

    #24050

    Marcos Ivanechtchuk
    Participant

    Lincoln,

    Sorry… just zipped the project folder.

    Attachments:
    1. test1.zip
    #24055

    Okay, Christian and I were able to find the root of the problem. It looks like you are attempting to use the OmniFaces “Extensionless URLs” feature, which appears to completely break PrettyFaces. They do not actually do this correctly, which will in fact also break things like the CDI conversation scope and the JSF2.2 WindowScope.

    I would remove the following configuration from your web.xml, and use PrettyFaces for this instead:

    	<context-param>
    		<param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
    		<param-value>/*.xhtml</param-value>
    	</context-param>

    You can do the same thing in rewrite/prettyfaces using a rule like this (from the rewrite examples – http://ocpsoft.org/rewrite/examples/#section-2):

    public class ExampleConfigurationProvider extends HttpConfigurationProvider
    {
       @Override
       public Configuration getConfiguration(final ServletContext context)
       {
          return ConfigurationBuilder.begin()
              .addRule(Join.path("/{page}").to("/{page}.xhtml"))
              .where("page").matches("\\w+"); // customize this matches pattern for your needs
       }
    }
    #24056

    Just for example’s sake, here is the demo app as I was able to reproduce the issue. Comment out the EXTENSIONLESS URLS feature in the web.xml to resolve issue:

    Attachments:
    1. test.tar.gz
    #24068

    Marcos Ivanechtchuk
    Participant

    Awesome!

    Thanks very much for you GREAT support, Lincoln and Christian.

    Unfortunately, attempting to deploy the rewrite/prettyfaces jars to original app, i’ve got a new error, “failed to load configuration”.
    It seems now to be a error caused by SeamFaces. I tried to use another versions, but without success. Could you light something to resolve?

    Open new post: http://ocpsoft.org/support/topic/failed-to-load-configuration-2/
    Seem to be related: http://ocpsoft.org/support/topic/exception-starting-filter-pretty-filter/

    Regards,

    Marcos

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.

Comments are closed.