thanks....
i think it can be my solution....but i've no idea about doing it.....
can you help me,please?
You're my only hope,it's the first solution that someone says for my
problem.........
Can you help me with initial code and help?
> thanks....
> i think it can be my solution....but i've no idea about doing it.....
> can you help me,please?
> You're my only hope,it's the first solution that someone says for my
> problem.........
> Can you help me with initial code and help?
I'll try to outline what I would have done:
1) Create a bean that stores the fieldValue (the desired number of fields)
2) Create a form for the fieldValue that navigates to the page where the
dynamic form is displayed once it is submitted, e.g.
action="#{toDynaForm}". You need to specify a navigation rule in the
faces-config.xml for this.
3) The dynaform page should contains at least something like this:
<h:form action="#{ActionClass.processForm}">
<h:panelGrid binding="#{dynamicForm.formElements}" />
</h:form>
4) Now have a look at the DynamicForm class I earlier posted. First, you
fetch the fieldValue from the bean that was sent. Then, you can create a
for-loop which just generates the desired HtmlInputText() objects.
5) Every HtmlInputText object needs to be binded to a bean variable.
(see the DynamicForm example). That's what the 'setValueBinding' method
does.
In your case, I think there's no clean solution to create a bean that
efficiently stores this values. I'd create a bean with a HashMap. When
the dynamicForm is built, you can initialize this map with keys that
have empty values. For example, each time a new HtmlInputText() is
created, you add a record to the map:
Map().put(""+fieldValue+counter, ""); (Where counter increments for
every field within the current row).
Now, you can bind the field value to the value of this key:
String bind = "#{Map[""+fieldValue+counter]}";
hit.setValueBinding("value",
getApplication().createValueBinding(bind));
6) When the dynaform page is submitted, you can fetch the bean Map in
the processForm() function and upload the data to a database.
I am no JSF expert, and it took me some time to understand this, too :)
I do think that this implementation conforms to the JSF framework the
most, but there might be easier (but dirtier) solutions using old JSP tags.
gbattine - 14 Aug 2006 13:07 GMT
thanks very much....
but it's too difficult for me and i have no too time now....
i've thinked a stupid solution but i don't know if it is correct.
Can you help me?
I've thinked so:
Suppose my application needs maximum 10 form(depending on user's
choice), i create the 10 forms and i use rendered attribute to shows
them watching the user's number.
If user insert 5 the forms from 6 to 10 aren't displayed....
i don't know if i can use this solution....
can you say me if it can be correct?
Thanks very much
Moiristo - 14 Aug 2006 17:19 GMT
> I've thinked so:
> Suppose my application needs maximum 10 form(depending on user's
[quoted text clipped - 4 lines]
> can you say me if it can be correct?
> Thanks very much
When a user can enter any number, you need to think about a solution on
how to save all data in the backing bean. If you can be sure that a user
will not choose a number above 10, then this is a good solution. The
only thing you need to do is create a function that can be called by the
render attribute, which returns true while the desired number of fields
is not reached.
Greetz,
Moiristo
PS. I have been doing a lot of searches on the internet to find a
solution to send parameters to a method with JSF EL, e.g.
#{bean.toUppercase['string']}. Today, I found a solution, which can be
very useful in this case (I guess). Link:
http://www.nabble.com/a-way-to-pass-parameters-in-el-expressions-t2084266.html