How do I find parameter values from EntityQuery<T> class? - seam

I have a seam 2.2 app. Basically I have a form with about 30 input fields. Each field is backed by a property is SearchForm.java. When I click "Submit" I invoke DevicesList.java (implements EntityQuery) and jump to /DevicesList.xhtml. All the input fields and properties correspond to parameters listed DevicesList.page.xml.
In other words in DevicesList.page.xml we have
<param name="hostname" value="#{searchForm.devName}"/>
<param name="loopback" value="#{searchForm.devIp}"/>
<param name="platform" value="#{searchForm.platform}"/>
etc.
I am heavily customizing getEjbql() based on which searchForm properties are set. I have been stepping through the seam framework code and trying to find a datastructure to access that contains a list of parameters that have been set from the form. Where are these things?
If I have entered a string into the hostname field of the form, the hostname parameter must be set to the value of #{searchFrom.devName}. But how do I find out that the hostname parameter has been set?
The only alternative I can think of is to use reflection and loop through all the classes of SearchFrom and then perform introspection on the object to see which ones have been set and build my sql query from that.
There has to be a better way. Anyone know how this could be done?

This is done automagically by Seam, meaning that it won't add a restriction for a field of the form that has no value, so if the user only inputs data on the, for example, devName and devIp fields, then the query will be something like:
select d from Device d where devName = ? and devIp = ?
even if your DevicesQuery also adds 27 more restrictions for all the fields, they won't be added to the query because they are empty

Related

Laravel Form input type="text" select data from another table on type type suggest existing data from the table and select

How can i create a form like the one on linkedin. On form input type when i type is going to fect data from a database if not existis is going to create it and fetch d and store to another table
on form input type, immediately get result: This can be done by AJAX. Laravel support Vue which can do this easily:
1a. call a function in the mounted() part.
1b. the function call itself by putting setTimeout(this.functionName,1000) at the end.
1c. in the function, check if the text in the text box is changed. if yes, make a request by axios.get('blablabla').then(response=>{//put the response into vue dataArrayName in data part});
1d. the html template is auto-updated by v-for="dataArrayName"
looks like the search is done by comparing char by char from the beginning of the string to the data.
if you press enter, pass the search string to the controller, use some logic to determine whether it is needed to create row in database

How to print Activiti workflow task's values into Alfresco Share

I have a workflow to manage employee petitions, that starts with some fields at starter form. The next task, allows a responsable user to approve or reject the initiator user's petition.
I want to show the values of starting form into the approve/reject form, so I created a custom .ftl file for every field that I want print the label and the value. Now I have hard-coded the values to the this:
My problem here, is how to get the value from the first form and print it at the second form (values that I need are where says "200€" and my name).
I'm using Alfresco Community 5.1 and his own Activiti.
Thanks.
Solution 1 : keep IDs of the fields identical in both the forms. this will make the field editable in the second form.
Solution 2 : create a process variable, set its value after the first form has been submitted. then, in the second form display the value of the process variable.

Drupal views 3 - missing "MULTIPLE FIELD SETTINGS" in entity reference

Context: Content type Person has reference (multiple values) to a content type Work, using entity reference.
Need: To display the title of each person node which references a given work, separated by a comma.
Done: A view with a back reference, the right nodes are fetched. (Views 7.x-3.7)
Problem: Cannot display the value separated by a comma. Note: I usually do it with the "Simple separator" display type which is under "Display all values in the same row" in the MULTIPLE FIELD SETTINGS field group. However, this field group is not available in my context.
Solved
I have found the module Views Merge Rows - works very nice. If it does not support Features module for some reason, I can take some of its code code in order to use hook_views_pre_render myself.
I was able to work around this problem by using token_formatters. The basic steps (after token formatters is installed):
No relationship to referenced entity in views (not needed)
Add the entity reference field to the view
Change formatter to "tokenized text"
For 'Text to output' use a token (I'm using [node:field-name])
For 'link destination' use a token ('m using [entity:url:path] for a relative link)
Set multiple field setting as desired
You need a custom views Format here because you are talking about the whole views-row not a multiple results field. You can use the "Unformatted list" and add a comma to be added with CSS or JS.
What kind of Relationship do you use? Can you export your whole views in an external editor and provide a link?
I had a similar issue, where I was using the Entity Reference relationship of "Referencing Entity" instead of "Referenced Entity". (The reference was on the child and the View started at the parent level).
When you run a Drupal System Message on the row (dsm), it returns all the nid responses appropriately, but as different result rows instead of as a single object; however, since the NID field (like many others) has no option for display multiple results, it would only grab the first result.
I ended up having to do an Entity Query from a Views PHP field with the current row's NID as one of the Field Conditions. That seemed to do the trick, rather than trying to load a View inside of a View with views_field_view.
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', '[your_content_type]')
->propertyCondition('status', 1)
->fieldCondition('[your_field_machine_name]', '[field_column_to_check]', $row->nid)
->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();
I had a very similar problem: no "Multiple Field Settings" were available in the field configuration of a multi-value entity reference from my content type to User.
Solved it by removing the entity reference and instead using the multi-value "User ID" field of my content type directly. The "Multiple Field Settings" form area was available now and I selected "Display all values in the same row" there as you do normally. Now this would only display numeric user IDs separated by comma (not desired). But in the field configuration there was also a setting "Format:", which I set to "Label". This would display user names instead.
So I guess by creating a custom formatter you would be able to display your associated "Work" entities in a similar way.

Reuse fields in an ASP.NET form

I have an online form that collects the user's contact information. Typical stuff - first & last name, address, city, state, zip, etc.
At one point in the process, they can enter information for another person as well. At that point, I show a modal popup with the very same fields for this other person.
I hate the repetition of the fields in my ASCX file. I'd like to define a single block of fields and show them in different contexts.
A twist to the plot is that the admin of the site can configure which fields are visible for each of the two contexts.
For example, they might say for the primary user, we want to ask for phone number, but we don't want to show that field for the additional people. In that situation, the phone number field would be visible for the main form, but hidden in the modal popup.
So the question is: What is the best way to reuse the same fields in different places of an ASP.NET form?
You can add another flag to your user control
Note : this flag must be declared as public property
public bool Flag
{
get;
set;
}
Your User control
First instance : <UCTagPrefix:UCTagName runat="server" id="" Flag="true"/>
Second instance : <UCTagPrefix:UCTagName runat="server" id="" Flag="false"/>
you can use another type if you want, this sample is based on boolean
Adapt the behavior of your user control with the value of your flag , in your code behind
If admin wants to configure visibility of each field, I think it would be better to add the field list to a database table like fieldName, userType1 (bit), userType2 (bit),... and then add the value 0 or 1 (Admin could do this via interface).
When you load the control get the corresponding values by passing userType to the database (stored procedure or query) and set visibility of each field accordingly.

How can I set a schema.Datetime field to None with Dexterity

I'm writing a simple content type with Dexterity to manage customers, beside the usuals fields, eg name, company, phone...
I've also added a Datetime field to store when the first meeting with
customers has been held, lets call it 'firstmeeting', which I defined
in my interface ICustomers as:
firstmeeting = schema.Datetime(
title=_(u"First Meeting"),
required=False,
)
Now, I notice that when I saved a new Customer document the firstmeeting
field has been filled with the current date even if I don't set any date
in the form, which is not what I want because no meeting with the
customer has been held yet. So I'd like to know how to set a None value
for this field so nothing will be displayed.
I've been trying to use a custom class has explained by Martin Aspeli in
http://plone.org/products/dexterity/documentation/manual/developer-manual/advanced/classes
but I don't know how to check the user input and set None value if nothing
was typed in.
Thanks
Have you tried default=None?
I found out what was happening in my code.
Actually the problem was in the template view.pt where I used toLocalizedTime() function,
which was converting the None value to the current date, so I added a tal:condition to print the date value.
<span id="form-widgets-firstmeeting" class="datetime-widget datetime-field"
tal:condition="context/firstmeeting"
tal:content="python:context.toLocalizedTime(context.firstmeeting)" />

Resources