Java Wickets Dynamic DataView

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Java Wickets Dynamic DataView

ASHU_JAVA
Hello All,

I'm trying to have a dynamic list view which will get updated dynamically on a button click.
I've to implement the functionality like below:-



So, the user will pass either a single name or upload a file containing many names, an addition in database is performed in the background by clicking the button "ADD".
On success, the DataView should update the list of names as shown in tabular form in above image with the newly added one.

I'm using a model window that contain this form and would like to update the list (DataView) section on clicking the ADD button.

Kindly suggest your inputs/code sample to achieve this.

Thanks in advance.

Reply | Threaded
Open this post in threaded view
|

Re: Java Wickets Dynamic DataView

Pedro Santos
Hi Ashu,

just make sure the the add button inside the modal re-renders the
DataView. If the input data was correctly add to the database, the
DataView's IDataProvider should correctly start to provide them and
they will show up in the response.

cheers
Pedro Santos


On Thu, Feb 2, 2017 at 4:29 PM, ASHU_JAVA <[hidden email]> wrote:

> Hello All,
>
> I'm trying to have a dynamic list view which will get updated dynamically on
> a button click.
> I've to implement the functionality like below:-
>
> <http://apache-wicket.1842946.n4.nabble.com/file/n4676976/Sample.png>
>
> So, the user will pass either a single name or upload a file containing many
> names, an addition in database is performed in the background by clicking
> the button "ADD".
> On success, the DataView should update the list of names as shown in tabular
> form in above image with the newly added one.
>
> I'm using a model window that contain this form and would like to update the
> list (DataView) section on clicking the ADD button.
>
> Kindly suggest your inputs/code sample to achieve this.
>
> Thanks in advance.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Java-Wickets-Dynamic-DataView-tp4676976.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Java Wickets Dynamic DataView

ASHU_JAVA
Thanks Padro for your response.
I'm a newbie to Java Wickets, so can you please share some more insights regarding this.

I'm using below code:-

public class MyPanel extends Panel {

private MyBean domain;
	/**
	 * Create pages with commons components
	 * 
	 * @param modal
	 */
	private void createComponents(final ModalWindow modal) {
		container = new WebMarkupContainer("container");
		add(container);

		Form<Void> form = new Form<Void>("form");
		form.setOutputMarkupId(true);
		container.add(form);

		CheckGroup group=new CheckGroup("group");
		form.add(group);
		group.add(new CheckGroupSelector("groupselector"));
		
		final Label labelname = new Label("labelname", "Enter Name :");
		form.add(labelname);

		final TextField<String> name = new TextField<String>("name", new Model<String>());
				
		form.add(name);

final FeedbackPanel feedback = new FeedbackPanel("feedback");
		feedback.setOutputMarkupId(true);
		container.add(feedback);

		final Label labelname2 = new Label("labelname2", "Select File to Upload:");
		form.add(labelname2);

		final AjaxButton filesendButton = new AjaxButton("fileSend") {
			
			@Override
			public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                        ............
                        }
               };

// Add Upload button
		form.add(filesendButton);
		
		form.add(fileUpload = new FileUploadField("fileUpload"));
		
		// Enable multipart mode (need for uploads file)
		form.setMultiPart(true);
		
		final AjaxButton closeButton = new AjaxButton("closeButton") {

			private static final long serialVersionUID = 1L;
	@Override
			public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
				modal.close(target);
				setResponsePage(page.getPageClass());
				target.add(page.setOutputMarkupId(true));
			}

			@Override
			protected void onError(final AjaxRequestTarget target, final Form<?> form) {


			}

		};
		
		Form<Void> closeForm = new Form<Void>("closeForm");
		closeForm.setOutputMarkupId(true);
		container.add(closeForm);
		closeForm.add(closeButton);
		closeButton.setVisible(false);
		
		//<h2>Add user code</h2>
AjaxButton addName = new AjaxButton("Add") {
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
					domain.setDomainname(name.getModelObject());
						
						if(CreateUser(domain)){
						
						info("Modification done");
						}
Form<Void> formList = new Form<Void>("userList");
		formList.setOutputMarkupId(true);
		container.add(formList);
		
		
		MyUser mUser=null;
		ArrayList list = manageUserStoreDomain.findUsers(domain.getDomainname());
		ArrayList finalList = new ArrayList();
		    for (int i1 = 0; i1 < list.size(); i1++) {
	     
	            mUser = new DomainUser((String)list.get(i1));
	            finalList.add(domainUser);
	        }
		final DataView dataView = new DataView("userTable", new ListDataProvider(
                list)) {
        	@Override
            public void populateItem(final Item item) {
        	      item.add(new Check("checkbox", item.getDefaultModel()));
                final MyUser user = new MyUser((String)item.getModelObject());
                item.add(new Label("userid", user.getId()));
                
                
            }

		
        };
        
		final WebMarkupContainer wmc = new WebMarkupContainer("container");

		wmc.add(dataView);

		wmc.setOutputMarkupId(true);
        group.add(wmc);
        formList.add(group);
        
	}

<raw>	
HTML code:

<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
</wicket:head>
</head>
<body>
	<wicket:panel>
		<div class="containeruistore" wicket:id="container">
			<div class="page-header">
				<h1>
					<wicket:message key="title.userlist" />
				</h1>
			</div>
			<div wicket:id="feedback"></div>
			<form wicket:id="form">
				<div>
					<span wicket:id="labelname"> </span> 
					<input type="text" wicket:id="name"></input>
				</div>
				
				<p id="ORID">OR</p>
				
				<div>
					<span wicket:id="labelname2"></span> 
					
				</div>
				<div>
				
				<input wicket:id="fileUpload" size="40" type="file" style="width:60% important!" />
				
				</div>
				
				<div style="text-align: center">
					<input wicket:id="Add" type="submit" value="Add"/>
						
				</div>
				
				
				
			</form>
			<form wicket:id="closeForm">
				<div>
					<input type="button" value="close" wicket:id="closeButton"/>
				</div>
			</form>
			
			<form wicket:id="userList" style="border-top: 3px solid #D3D3D3;">
			<div>
			<span wicket:id="group">
			<input type="checkbox" wicket:id="groupselector">check/uncheck all</input>
			<table cellspacing="0" class="dataview">
    
    			<tr>
    				<th>List of users</th>
    			</tr>
       			<tr wicket:id="userTable">
       			<td><input type="checkbox" wicket:id="checkbox"/></td>
         			<td><span wicket:id="userid">Test ID</span></td>
       			</tr>
    
			</table>
			
			</span>
			</div>
			

			
			
			
			</form>
			
		</div>
	</wicket:panel>
</body>
</html>


I'm able to add user to database, but unable to refresh the list with new list entry.

Kindly provide your inputs.

Thanks in advance.
                                       

               
Reply | Threaded
Open this post in threaded view
|

Re: Java Wickets Dynamic DataView

Pedro Santos
You can change your ListDataProvider to load data at each request like:

new ListDataProvider(){
List<T> getData() { if (list == null)  list =
manageUserStoreDomain.findUsers(domain.getDomainname()); return list;
}
void detach(){ list = null;}
}

or to use any IDataProvider implementation that is affected by you transaction.

Cheers
Pedro Santos


On Tue, Feb 7, 2017 at 2:31 PM, ASHU_JAVA <[hidden email]> wrote:

> Thanks Padro for your response.
> I'm a newbie to Java Wickets, so can you please share some more insights
> regarding this.
>
> I'm using below code:-
>
>
>
>
> I'm able to add user to database, but unable to refresh the list with new
> list entry.
>
> Kindly provide your inputs.
>
> Thanks in advance.
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Java-Wickets-Dynamic-DataView-tp4676976p4677010.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]