I believe the backend code of UIInput and similar components has logic that
dot not update model values if readonly or disabled is set to true.  I
believe a workaround to this would be to either create a custom tag that
would mark the field as readonly on page load or just embed javascript into
your page directly to change the input field to readonly.  For example:

That way, on page load, your field is marked readonly, but the state saved
values are non-readonly, so the browser should submit the value back to the
server, which should then update the model values appropriately (providing
no validation/conversion errors exist).

One thing to note is that if you mark the field as disabled, then the
browser will not submit the value (at least I think most browsers follow
that logic), so your best bet is to mark it readonly.

Nick


-----Original Message-----
From: raindogs [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 19, 2007 10:42 AM
To: [email protected]
Subject: passing a value to the bean from a read-only field


I am using the Jenia pop-up calendar to allow the user to input a date. What
I would like to do is have link to show the calendar below a text field
("requestDate") that displays the user's selection from the calendar. That
all works fine, but the user is still allowed to go in and monkey with the
text after he/she has selected from the calendar. Ideally the field would
display the value selected but would not allow it to be edited. I have tried
adding "readonly" and "disabled" attributes to the field, which achieves the
desired effect but does not pass the value back to the bean when the page is
submitted. Can anyone suggest how to move forward on this? The bean is
session-scoped and my code snippet is below.

Thanks,
Alex


        <tr>
        <td>
        <h:outputText value="Date of Request" />
        </td>
        <td>
        <h:inputText id="requestDate" value="#{arfOrderForm.requestDate}" >
                <s:convertDateTime pattern="MM/dd/yyyy" />
        </h:inputText>
        
        </td>
        </tr>

        
        <tr>
        <td>
        </td>
        <td>
                <jp:popupCalendar for="requestDate" format="MM/dd/yyyy">
                        <h:outputText value="Choose Date"/>
                </jp:popupCalendar>
        </td>
        </tr>

-- 
View this message in context:
http://www.nabble.com/passing-a-value-to-the-bean-from-a-read-only-field-tf3
427871.html#a9554596
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to