-
1. Re: Design question: should JSF components be accessed in session EJBs?
mmichalek.mmichalek.micros-retail.com Apr 2, 2008 8:19 PM (in response to benmoore)What is the value of your HtmlInputText bound to? Can you pull the updated value from that object?
-
2. Re: Design question: should JSF components be accessed in session EJBs?
benmoore Apr 2, 2008 8:59 PM (in response to benmoore)The HtmlInputText isn't bound to anything right now:
<rich:dataTable value="#{properties}" var="mapEntry"> <rich:column> <f:facet name="header">Name</f:facet> <h:outputLabel for="value" value="#{mapEntry.key}"/> </rich:column> <rich:column> <f:facet name="header">Value</f:facet> <h:inputText id="value" value="#{mapEntry.value}"/> </rich:column> </rich:dataTable>
properties is a Map<String, String>
-
3. Re: Design question: should JSF components be accessed in session EJBs?
benmoore Apr 2, 2008 9:14 PM (in response to benmoore)
Ben Moore wrote on Apr 02, 2008 08:59 PM:
The HtmlInputText isn't bound to anything right now:<rich:dataTable value="#{properties}" var="mapEntry"> <rich:column> <f:facet name="header">Name</f:facet> <h:outputLabel for="value" value="#{mapEntry.key}"/> </rich:column> <rich:column> <f:facet name="header">Value</f:facet> <h:inputText id="value" value="#{mapEntry.value}"/> </rich:column> </rich:dataTable>
properties is a Map<String, String>Mistake, of course. The input boxes are bound to the Map, but changing them doesn't change the Map.
How else can this be done without using JSF in the session EJB?
-
4. Re: Design question: should JSF components be accessed in session EJBs?
pmuir Apr 5, 2008 8:29 PM (in response to benmoore)
Ben Moore wrote on Apr 02, 2008 07:52 PM:
None of the Seam examples use binding="" attributes on Faceletes pages. None of the Seam examples reference any UIComponent from Seam components (whether they be EJBs or POJOs).
So the answer to my question would appear to beno
, but I cannot figure out the following:Almost certainly not a good idea - you are tying the view too closely to the business layer.
Assuming you use a <c:forEach /> this should work.
-
5. Re: Design question: should JSF components be accessed in session EJBs?
benmoore May 23, 2008 4:12 PM (in response to benmoore)
Pete Muir wrote on Apr 05, 2008 20:29:
Assuming you use a <c:forEach /> this should work.Sorry to dig up this old thread, but I'm back to this same problem again. The map isn't getting updated when the user makes changes. Pete, where exactly should I be using <c:forEach/> ? Are you saying I should use that instead of <rich:dataTable/> to render the labels and input boxes?
Thanks,
Ben -
6. Re: Design question: should JSF components be accessed in session EJBs?
dan.j.allen May 24, 2008 12:32 AM (in response to benmoore)I'll agree that this isn't the most shining part of JSF, but there is a way to accomplish this thanks to Seam.
First, your problem is that Map.Entry is not writable, so you cannot bind directly to the value property. What you need is two context variables, one native map, one Seam's DataModel wrapper. Here is the action bean:
`@Name("propertyEditor")
@Scope(ScopeType.CONVERSATION)
public class PropertyEditorAction implements Serializable {
@DataModel
private Map<String, String> propertiesModel;
@Out
private Map<String, String> properties;
@Begin(join = true) @Factory("propertiesModel")
public void retrieveProperties() {
this.propertiesModel = this.properties;
}
public void save() {
}
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
}`
Then in the UI:
`<rich:dataTable value="#{propertiesModel}" var="mapEntry">
<rich:column>
<f:facet name="header">Name</f:facet>
<h:outputLabel for="value" value="#{mapEntry.key}"/>
</rich:column>
<rich:column>
<f:facet name="header">Value</f:facet>
<h:inputText id="value" value="#{properties[mapEntry.key]}"/>
</rich:column>
</rich:dataTable>`
Notice how I have the native map and the data model work together to negotiate the update.
<span style="font-size:x-small;">As a side note, I first tried |#{propertiesModel.wrappedData[mapEntry.key]}|, but it didn't work because Seam's map data model returns a transient map that disappears, not the native one.</span>