I have search page, on subitting the search parameters to the search controller, the controller populates the search result in the list and it should return to the same page
Also, in the search result i, should have two buttons update and delete, which will update the search result.
Please help, how it should be implemented.
I would recommend 4 controller (methods - in Spring 3.0 you can handle several requests in one controller, I do not know if this is possible in 2.5 too)
one for search
one for delete an item
one (update-form controller) to return the update form
one (update controller) to change the item with the data from the update form
(You can use a SimpleFormController (deprecated in 3.0) to handle the update-form and update change with one controller.)
The search controller takes the search phrase returns an view with several forms:
* One to enter a new search phrase and invoke the search controller again.
* One delete form (just the submit button and an hidden field to identify the item) for each item. - If you want to show the search results again after the delete, you need to add the search phrase in a hidden field of this form to, to be able to redirect to the search result with the correct search phrase after deleting.
* One Link that invokes the update form (containing a attribute to identify the item) for each item.
The delete controller takes the item identifier to find the item to delete. And takes the search phrase to redirect to the search controller after deleting.
The update-form controller takes the item identifier to load the item and return a form to update the item, populated with the items values. - This form "invoke" the update controller. - The form must also contain the identifier of the item to change.
The update controller takes the new values and validate them. If they are valid it takes the item identifier to load the item and then modify the values. If the items are not valid, it returns the same view like the update-form-controller but uses the new (changed) values.
Related
I am trying to create a search form for a website where you can find movie reviews. As such, the user should be able to search for their movie by entering either the movie title or the imdb id or the year of release. However, the user should also not be allowed to search with a blank form.
class SearchForm(FlaskForm):
movie_title = StringField('Movie Title', validators=None)
imdb_id = StringField('IMDB_ID', validators=[Length(min=9,max=9)])
year = IntegerField('Year of Release', validators=[Length(min=4,max=4)])
submit = SubmitField('Search')
This is my current form.
However, due the length validtors in place for imdb_id and year, the user is unable to submit the form if they leave the beforementioned two fields empty as an empty field does not meet the minimum length of 9 and 4 respectively. Is there anyway to work around this such that a form is only validated if it is filled in?
You need to provide a method which checks all the appropriate fields and ensures that at least one has content. Then you can check the prerequisite in the form validation method.
class SearchForm(FlaskForm):
# ....
def any_fields_filled(self):
return any(self.movie_title.data, self.imdb_id.data, self.year.data)
def validate(self):
return self.any_fields_filled()
Then you need to mark the fields as Optional, e.g.:
imdb_id = StringField('IMDB_ID', validators=[Optional(), Length(min=9,max=9)])
If you find yourself needing to consult any_fields_filled() as part of one of the validators you declare on an individual field, you can either use a method instead (validate_field_name()) or you can use the If() validator in the WTForms-Components library.
I'm starter to use JHipster. One of my entity A has more than 3000 data. So I used infinite-scroll as pagination. But as relation to another Entry B, it will be generated as a comboBox in the dialog. I got only 20 data in the comboBox. There is no infinit-scroll or search and loading to get more data.
Can someone give any advice to fix the problem?
The infinite scroll uses pages (which is mapped to pageablea in spring). Thus, your service call that fetches the data for the box only fetches the first page. And the default page size is 20. So, you need to increase the page size to get more results.
You can either overwrite the "size" variable or the global constant called "itemsPerPage" which is located in pagination.constants.js
Am I right that it is a one-to-many relationshiop and you want to choose one of 3000 possible A for an entity B?
If so, you don't want to load all 3000 possible As into the dropdown. Therefore, I would replace the dropdown with another input, e.g. the typeahead from angular-ui (https://angular-ui.github.io/bootstrap/#/typeahead), so you can fetch a filtered subset of your entities.
Another way, I also used before, would be a list with a pagination for A that opens in a modal and returns the selected entity that could be passed to b.
Or, if you really want to fetch all: I would add a new endpoint without the pageable, add a new method to the angular-resource-service and call this instead of the paged version.
I'm creating a student assignment submission application using xpages (8.5.3 FP3 UP1). The details are:
Student can do any number of submission. For each submission, a unique SubmitID will be created. For now,
a. The Form (Submit) - 2 fields only (SubmitID, SoftCopy-RTF type)
b. The View (Submit) - 2 column only (SubmitID, AttachmentNames)
c. Examples of SubmitID are: submit1, submit2
For each submission, student must select what course/subject that submission is for (eg: Maths, Physics etc). Therefore I've already created another form for the teacher to create the list of subject
a. The Form (Subject) - 1 field only (SubjectName)
b. The View (Subject) - 1 column only (SubjectName)
c. Say for now 2 subject has been created - Maths & Physics
I've created 2 xpage:
a. Submit.xsp - to create new submission (using form - Submit)
b. SubmitView.xsp - to display the list of submission (using view - Submit)
For Submit.xsp, here's where my problem begins:
a. The controls in here are as follows: SubmitID EditBox, Repeat Control(inside is a CheckBox, a fileUpload, and a fileDownload)
b. The repeat is based on the list of subject available. The CheckBox title will be each of the SubjectName. In the OnChange event of the fileUpload control, each time after a file is browsed, the checkbox will get checked and this worked.
c. The fileUpload should only update the accompanying fileDownload but instead the attachment that I just uploaded is reflected to every other fileDownload control. I'm doing full refresh on the fileUpload OnChange because that's the only way for the fileDownload to be updated. What is wrong here and what should I do to get the result that I wanted? Saving the document and opening it later in both read-only or edit mode is fine although each subject still display the same list of uploaded files. Both fileUpload and fileDownload are binded to the SoftCopy field.
Unless I'm not correctly interpreting your description, you're binding multiple upload / download controls to the same item ("SoftCopy"). Because these controls are always bound to an item, not to each other, a download control will show any attachments stored within the source item, regardless of how they got there. To limit display of attachments in a download control to those sent via a specific upload control, they must be stored in an item unique to that pair.
For example, if each pair were bound to a subject-specific item, such as "SoftCopy_Maths" or "SoftCopy_Physics", then each download would only display attachments stored within that specific item. You don't know what subjects will be defined, so you can't define these fields on the form, but that's okay... you don't need to. NSF has no schema, so a field need not be defined on a form for a control to be bound to it; the item will be created when the document is saved, even if the form does not define it. Strictly speaking, even the form itself need not exist.
We typically bind controls to items using dot syntax, e.g. #{currentDocument.SoftCopy}, but array syntax is equally valid, e.g. #{currentDocument["SoftCopy"]}. So if you wrap these controls in something that establishes the dynamic item name as a variable or property, you can use array syntax to target that dynamic item. Two of the best ways to do this are data contexts and custom controls.
For instance, you could surround the contents of the repeat in a panel, and define a panel-specific dataContext that associates the variable attachmentItemName with the concatenation of the item name prefix and the specific subject. Your upload and download controls can then be bound to #{currentDocument[attachmentItemName]}.
Alternatively, you can move the same content to a custom control that accepts the data source and item name as properties, in which case your value binding might look like #{compositeData.dataSource[compositeData.attachmentItemName]}.
Apart from very minor differences in runtime performance, either approach is equally valid.
I have a profile weblog that contains all our users details (fields seperate from the membership).
These users can submit application forms with the use of a SAEF (stand alone entry form), which will be stored in an applications weblog. Inside this applications weblog, I have a relationship field which assigns a profile to an application.
Inside this application, radio buttons are contained to allow an admin to change the status of that application (an example, a judge views an application for Joe Bloggs and sets this application to “winner”).
What I essentially need to do is filter out all the profiles that have not been set to a number of status’. So if I apply for an application and the judge is yet to view this application, my profile should not appear in the search results. My idea of this is that I would somehow have to intertwine search results with a reverse related entry tag, and as my knowledge of the search module is limited I am at a complete loss if this is even possible.
As you can see, not only do I need to search by custom field, but the profiles that will be displayed should be determined on custom fields contained in the application entry.
I would suggest using the "status" option instead of the radio custom field.
Why? Because you can accomplish the same thing you want to do with the radio field and you can set what entries you want to return in your search results.
For example, you have a status group called: "Application", which is assigned to the that weblog/channel
Within the status group, you will have three options: Pending (waiting to be looked at), Loser (judge sets it to this because it is not a winner, or just as pending), Winner (judge considers that application a winner).
Then in the search tag, you would set what statuses it will return in the search results
so if you want to only return applications/profiles that were marked winner, you would set the status="status_id" (this will be the id of "Winner" status)
In my web application I got a search results list (SR). The search is heavily parametrized. Each element on the list can be clicked and then the element's own page (EP) is displayed.
Now, the customer wants to have the ability to go to previous and next element from the search list that was used to enter the element page.
How would you implement this? I can either pass the search conditions to the EP and the element's index on the list, then prev/next would just mean to rerun the search query, get previous / next index and display it (still passing the conditions and new index).
Or is there a better approach?
How intensive is your search process? It sounds like something you don't want to execute anymore than necessary. What if you when you render the search results you also store in a list the unqiue EP IDs on the server. You can then navigate through that using indexes for prev/next and the unique ID of the EP element to load details? You can then also store the query term and repopulate the search results with a 'Back to Search' link?