1

i have multiple search forms, for five different databases (tables) each form contains about 30 - 40 search fields, which can be filled. I need all Params as GET-Params (because of SEO - for pagination) how can i submit them and get them without define 200 entrys in the .xhtml file (i think, to get them with facesContext is the way, how to recieve them)

thanks !

Sence
  • 115
  • 8

1 Answers1

0

Without <f:viewParam>, they are available by ExternalContext#getRequestParameterMap(). If the bean in question is request scoped, you can also use @ManagedProperty("#{param.name}") on the property declaration instead. You can only at earliest access them in a @PostConstruct method instead of the constructor. You'd also still need setters for them.

Note that you lose JSF-builtin conversion and validation this way. You'd need to do all conversion from String to for example Integer and do all validation on required parameters yourself instead of letting <f:viewParam> do its job.

See also:


Unrelated to the concrete problem, 200 parameters are pretty a lot. Even GET query strings have its limits. Does the view contain 50 conditionally rendered/included tables or so? Are you sure that you can't reuse a parameter for multiple purposes and have one common parameter which indicates how the other parameters have to be interpreted?

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Hey BalusC, how can i submit the Form, that i recieve all params as get values inside the url, the JSF PRG doesnt work. (post-redirect-get) with the old style
    .... more... it works, but it should be able to do with jsf or? i see only the param inside the url, if i define it inside metadata with ... thanks a lot!
    – Sence Feb 28 '12 at 21:33
  • Yes, just use `
    ` instead of ``. The `action` is not necessary (will default to current URL) and the `method` is not necessary (will default to GET already). An alternative is `` or `` should be wherein you nest the parameters as ``.
    – BalusC Feb 28 '12 at 21:46
  • if i do use h:form with h:link how can i use the values from the h:inputText Component in the f:param attribute of h:link ? thanks – Sence Feb 28 '12 at 21:51
  • So you have inputs? Then you can't use ``. Use a plain `` or ``. – BalusC Feb 28 '12 at 21:55
  • last question, do you know, how to build a HtmlCommandLink in a Bean function (with HtmlPanelGrid and binding in view) with a value expression like #{bean.doSomething()} , after that, all problems for the next 3 month should be solved :O – Sence Feb 28 '12 at 22:27
  • Can't you just render it conditionally? – BalusC Feb 28 '12 at 22:45